Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rahulmule/repositorypattern-dotnetrestapi
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.
https://github.com/rahulmule/repositorypattern-dotnetrestapi
dotnet-6 dotnetwebapi entity-framework-core repository-pattern sql-server-database
Last synced: 3 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/rahulmule/repositorypattern-dotnetrestapi
- Owner: RahulMule
- Created: 2024-01-05T22:10:52.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-01-05T22:17:34.000Z (10 months ago)
- Last Synced: 2024-11-11T00:16:35.267Z (3 days ago)
- Topics: dotnet-6, dotnetwebapi, entity-framework-core, repository-pattern, sql-server-database
- Language: C#
- Homepage:
- Size: 931 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Repository Pattern In Dot Net Web API using Entity framework core.
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.## Project Structure
The project structure follows a typical ASP.NET Web API pattern, utilizing Entity Framework Core for database interaction.
### DepartmentController
- **Description:** Manages CRUD operations for departments.
- **Methods:**
- `GetDepartmentById(int id)`: Retrieve a department by ID.
- `AddDepartment(Department department)`: Add a new department.### EmployeeController
- **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.## How to Run
1. Clone this repository.
2. Set up a SQL Server or another compatible database and update the connection string in `appsettings.json`.
3. Run the application using Visual Studio or `dotnet run`.
4. Test the API using a tool like [Postman](https://www.postman.com/) or [Swagger](https://swagger.io/).## Dependencies
- ASP.NET Core
- Microsoft.Extensions.DependencyInjection
- Entity Framework Core (assuming it's used in the repositories)
- Microsoft.AspNetCore.Http
- Microsoft.AspNetCore.Mvc## Repository Pattern
The project uses the Repository Pattern to separate data access logic from the controllers, promoting better code organization and maintainability.
### `IDepartmentRepository`
- **Description:** Interface for department data access.
- **Methods:**
- `GetDepartmentById(int id)`: Retrieve a department by ID.
- `AddDepartment(Department department)`: Add a new department.### `IEmployeeRepository`
- **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!