This repository contains a .NET Web API project showcasing implementation of Repository Design Pattern. Tech stack includes .Net 6, Entity Framework core as the Object-Relational Mapping (ORM) tool for interacting with a SQL Server database.
The project structure follows a typical ASP.NET Web API pattern, utilizing Entity Framework Core for database interaction.
- Description: Manages CRUD operations for departments.
- Methods:
GetDepartmentById(int id)
: Retrieve a department by ID.AddDepartment(Department department)
: Add a new department.
- Description: Manages CRUD operations for employees, including a dependency on the
DepartmentController
for validating department IDs. - Methods:
GetAllEmployee()
: Retrieve all employees.AddEmployee(Employees employee)
: Add a new employee, including validation of the associated department.
- Clone this repository.
- Set up a SQL Server or another compatible database and update the connection string in
appsettings.json
. - Run the application using Visual Studio or
dotnet run
. - Test the API using a tool like Postman or Swagger.
- ASP.NET Core
- Microsoft.Extensions.DependencyInjection
- Entity Framework Core (assuming it's used in the repositories)
- Microsoft.AspNetCore.Http
- Microsoft.AspNetCore.Mvc
The project uses the Repository Pattern to separate data access logic from the controllers, promoting better code organization and maintainability.
- Description: Interface for department data access.
- Methods:
GetDepartmentById(int id)
: Retrieve a department by ID.AddDepartment(Department department)
: Add a new department.
- Description: Interface for employee data access, including a dependency on
IDepartmentRepository
for validating department IDs. - Methods:
GetEmployees()
: Retrieve all employees.AddEmployee(Employees employee)
: Add a new employee, including validation of the associated department.
Feel free to customize and extend this project based on your specific requirements. For any issues or improvements, please create an issue or submit a pull request.
Happy coding!