The Inventory Management .NET Web API provides a robust backend solution for managing inventory. It includes a wide range of features designed to support modern web applications with efficient, secure, and scalable functionality.
- Key Features
- CORS (Cross-Origin Resource Sharing)
- Logging Service
- Repository Pattern
- DTO (Data Transfer Object) Classes
- Global Error Handling
- Model Validation
- Asynchronous Code
- Modular Design
- Advanced Querying Capabilities
- Paging
- Filtering
- Searching
- Sorting
- Rate Limiting
- JWT and Identity for Authentication and Authorization
- API Documentation with Swagger
- API Routes
- Getting Started
- Contributing
- Conclusion
- License
- Configured CORS to allow cross-origin requests from any origin, method, and header.
- Exposed pagination metadata in the headers.
- Implemented a centralized logging service to capture and manage logs, aiding in monitoring and debugging.
- Employed the repository pattern to abstract data access logic, making the code more modular and maintainable.
- Used DTOs to ensure a clear separation between the data models and API responses, improving data integrity and security.
- Integrated global error handling to manage exceptions consistently across the entire application.
- Implemented model validation to ensure data integrity before processing requests.
- Utilized asynchronous programming to improve performance and scalability.
- Structured the codebase into different classes and layers to promote modularity and reusability.
- Paging: Implemented pagination to handle large datasets efficiently.
- Filtering: Added filtering capabilities to retrieve data based on specific criteria.
- Searching: Integrated search functionality to allow quick data retrieval.
- Sorting: Enabled sorting to organize data based on user-defined parameters.
- Implemented rate limiting to control the number of requests a client can make to the API, ensuring fair use and preventing abuse.
- Utilized JWT and ASP.NET Core Identity for secure authentication and role-based authorization.
- Implemented refresh tokens for maintaining session security.
- Documented the API endpoints and models using Swagger for easy exploration and testing.
- .NET 8 SDK
- SQL Server (or any other compatible database)
-
Clone the repository:
https://github.com/YeabTesfaye/Inventory-Management-System cd Ultimate-Dotnet-Web-API
-
Set up the database:
-
Update the connection string in
appsettings.json
. -
Apply migrations:
dotnet ef database update
-
-
Build the project:
dotnet build
-
Run the project:
dotnet run
- Access the Swagger documentation at
http://localhost:3000/swagger
to explore and test the API endpoints.
I Register a new user
-
POST
http://localhost:3000/api/auth
-
Body:
{ "firstName": "string", "lastName": "string", "userName": "string", "password": "string", "email": "string", "phoneNumber": "string", "roles": ["string"] }
I Login a user
-
POST
http://localhost:3000/api/auth/login
-
Body:
{
"username": "string",
"password": "string"
}
The Customer Controller provides endpoints to manage customer data in the API. It supports CRUD operations, allowing you to create, retrieve, update, and delete customer information.
- GET
http://localhost:3000/api/customer/{customerId:guid}
- Description: Retrieves customer details based on the unique identifier.
- Parameters:
customerId
(guid): The unique identifier of the customer.
- Responses:
- 200 OK: Returns the customer details if found.
- 404 Not Found: If the customer is not found.
- GET
http://localhost:3000/api/orders/{orderId}/items
- Description: Retrieves all items associated with a specific order.
- Parameters:
orderId
(guid): The unique identifier of the order.itemParameters
(query parameters): Parameters for pagination and filtering.
- Responses:
- 200 OK: Returns a paginated list of items associated with the order.
- Headers:
X-Pagination
: Contains pagination metadata.
- GET
http://localhost:3000/api/orders/{orderId}/items/{itemId:guid}
- Description: Retrieves a specific item by its unique identifier.
- Parameters:
orderId
(guid): The unique identifier of the order.itemId
(guid): The unique identifier of the item.
- Responses:
- 200 OK: Returns the item details if found.
- 404 Not Found: If the item is not found.
- GET
http://localhost:3000/api/orders/{orderId}/items/product/{productId:guid}
- Description: Retrieves items associated with a specific product within an order.
- Parameters:
orderId
(guid): The unique identifier of the order.productId
(guid): The unique identifier of the product.
- Responses:
- 200 OK: Returns a list of items associated with the product within the order.
- POST
http://localhost:3000/api/orders/{orderId}/items
- Description: Creates a new item within a specific order.
- Parameters:
orderId
(guid): The unique identifier of the order.
- Body:
{ "productId": "guid", "quantity": "integer", "price": "decimal" }
- DELETE
http://localhost:3000/api/customer/{customerId:guid}
- PUT
http://localhost:3000/api/customer/{customerId:guid}
-- Body
{
"firstName": "string",
"lastName": "string",
"email": "string",
"phoneNumber": "string",
"address": "string"
}
The Item Controller provides endpoints to manage items within orders. It supports operations for retrieving, creating, updating, and deleting items.
- GET
http://localhost:3000/api/orders/{orderId}/items
- Description: Retrieves all items associated with a specific order.
- Parameters:
orderId
(guid): The unique identifier of the order.itemParameters
(query parameters): Includes options for pagination and filtering.
- Responses:
- 200 OK: Returns a paginated list of items associated with the order.
- GET
http://localhost:3000/api/orders/{orderId}/items/{itemId:guid}
- Description: Retrieves details of a specific item within an order.
- Parameters:
orderId
(guid): The unique identifier of the order.itemId
(guid): The unique identifier of the item.
- Responses:
- 200 OK: Returns the item details if found.
- 404 Not Found: If the item is not found.
- GET
http://localhost:3000/api/orders/{orderId}/items/product/{productId:guid}
- Description: Retrieves items associated with a specific product within an order.
- Parameters:
orderId
(guid): The unique identifier of the order.productId
(guid): The unique identifier of the product.
- Responses:
- 200 OK: Returns the list of items for the specified product.
- POST
http://localhost:3000/api/orders/{orderId}/items
- Description: Creates a new item within a specific order.
- Body:
{ "productId": "guid", "quantity": "integer", "price": "decimal" }
- GET
http://localhost:3000/api/customers/{customerId}/orders
- Description: Retrieves all orders associated with a specific customer.
- Parameters:
customerId
(guid): The unique identifier of the customer.orderParameters
(query parameters): Parameters for pagination and filtering.
- Responses:
- 200 OK: Returns a paginated list of orders for the specified customer.
- Headers:
X-Pagination
: Contains pagination metadata.
- GET
http://localhost:3000/api/customers/{customerId}/orders/{orderId:guid}
- Description: Retrieves a specific order by its unique identifier within a customer’s orders.
- Parameters:
orderId
(guid): The unique identifier of the order.customerId
(guid): The unique identifier of the customer.
- Responses:
- 200 OK: Returns the details of the specified order.
- 404 Not Found: If the order or customer is not found.
- POST
http://localhost:3000/api/customers/{customerId}/orders
- Description: Creates a new order for a specific customer.
- Parameters:
customerId
(guid): The unique identifier of the customer.
- Body:
{ "productId": "guid", "quantity": "integer", "price": "decimal" }
- GET
http://localhost:3000/api/suppliers/{supplierId}/products
- Description: Retrieves all products associated with a specific supplier.
- Parameters:
supplierId
(guid): The unique identifier of the supplier.productParameters
(query parameters): Parameters for pagination and filtering.
- Responses:
- 200 OK: Returns a paginated list of products for the specified supplier.
- Headers:
X-Pagination
: Contains pagination metadata.
- GET
http://localhost:3000/api/suppliers/{supplierId}/products/{productId:guid}
- Description: Retrieves a specific product by its unique identifier within a supplier’s products.
- Parameters:
productId
(guid): The unique identifier of the product.supplierId
(guid): The unique identifier of the supplier.
- Responses:
- 200 OK: Returns the details of the specified product.
- 404 Not Found: If the product or supplier is not found.
- POST
http://localhost:3000/api/suppliers/{supplierId}/products
- Description: Creates a new product for a specific supplier.
- Parameters:
supplierId
(guid): The unique identifier of the supplier.
- Body:
{ "name": "string", "description": "string", "price": "decimal", "stockQuantity": "integer" }
The SupplierController
provides endpoints for managing suppliers in the API. It includes operations for retrieving, creating, updating, and deleting suppliers. All endpoints are secured and require appropriate authorization.
- URL:
/api/suppliers
- Method:
GET
- Description: Retrieves all suppliers with optional filtering and pagination.
- Query Parameters:
supplierParameters
- Query parameters for pagination and filtering.
- Response:
200 OK
- Returns a paginated list of suppliers with pagination metadata in theX-Pagination
header.401 Unauthorized
- If the user is not authorized.
- URL:
/api/suppliers/{id:guid}
- Method:
GET
- Description: Retrieves a specific supplier by its unique identifier.
- URL Parameters:
id
- The unique identifier of the supplier.
- Response:
200 OK
- Returns the details of the specified supplier.404 Not Found
- If the supplier with the specified ID is not found.401 Unauthorized
- If the user is not authorized.
- URL:
/api/suppliers
- Method:
POST
- Description: Creates a new supplier.
- Request Body:
supplier
- The supplier data to create, in the form ofSupplierForCreationDto
.
- Response:
201 Created
- Returns the created supplier with a location header pointing to theGetSupplierById
action.400 Bad Request
- If the supplier data is null.422 Unprocessable Entity
- If the model state is invalid.401 Unauthorized
- If the user is not authorized.
- URL:
/api/suppliers/{supplierId:guid}
- Method:
DELETE
- Description: Deletes a supplier by its unique identifier.
- URL Parameters:
supplierId
- The unique identifier of the supplier to delete.
- Response:
204 No Content
- If the supplier is successfully deleted.404 Not Found
- If the supplier with the specified ID is not found.401 Unauthorized
- If the user is not authorized.- Role Required:
Administrator
- URL:
/api/suppliers/{supplierId:guid}
- Method:
PUT
- Description: Updates an existing supplier by its unique identifier.
- Request Body:
supplier
- The updated supplier data, in the form ofSupplierForUpdateDto
.- URL Parameters:
supplierId
- The unique identifier of the supplier to update.
- Response:
204 No Content
- If the supplier is successfully updated.400 Bad Request
- If the supplier data is null.422 Unprocessable Entity
- If the model state is invalid.401 Unauthorized
- If the user is not authorized.- Role Required:
Manager
I Retrieve a refersh token
- POST
http://localhost:3000/api/token/refresh
-body
{
"token": "string",
"refreshToken": "string"
}
We welcome contributions to improve this project. Please follow these guidelines:
-
Fork the repository.
-
Create a new branch:
git checkout -b feature/your-feature
- Commit your changes:
git commit -am 'Add new feature'
- Push to the branch:
git push origin feature/your-feature
## Conclusion
The Inventory Management System is designed to be scalable, secure, and easy to use. We encourage contributions and feedback to continually enhance the project.
## License
[MIT](https://choosealicense.com/licenses/mit/)