Welcome to the E-commerce API built with ASP.NET 6. This API facilitates typical e-commerce operations such as managing products, categories, orders, users, and administrative tasks.
- .NET 6 SDK
- SQL Server
- JWT Authentication: Secure your API endpoints using JSON Web Tokens for authentication.
- Generic Classes: Utilize generic classes to write reusable code for various data types and scenarios.
- SQL Server: Use SQL Server as the primary database for storing data.
- Entity Framework Core: Employ Entity Framework Core as the ORM (Object-Relational Mapper) for database interactions.
- LINQ: Leverage Language-Integrated Query (LINQ) for querying data from different data sources.
- DTOs: Implement Data Transfer Objects (DTOs) to transfer data between different layers of the application.
- MailKit & MimeKit: Use MailKit and MimeKit for sending and receiving emails within the application.
- Dependency Injection: Implement Dependency Injection to manage class dependencies and improve code maintainability.
- DRY Principle: Follow the "Don't Repeat Yourself" (DRY) principle to reduce duplication and enhance code readability.
- Repository Pattern: Implement the Repository Pattern to separate data access logic from business logic and improve testability and maintainability.
- Clean Architecture: Design the application following Clean Architecture principles to achieve separation of concerns and maintainability.
- Identity for Authentication: Utilize ASP.NET Identity for user authentication and authorization.
These features collectively enable the E-commerce API to provide robust functionality while maintaining code quality, security, and scalability.
- Endpoint:
/api/Account/Register
- Method: POST
- Request Body:
{ "firstName": "string", "lastName": "string", "phone": "string", "email": "user@example.com", "userName": "string", "password": "string", "confirmPassword": "string" }
- Response:
{ "token": "string" }
- Endpoint:
/api/Account/LogIn
- Method: POST
- Request Body:
{ "userName": "string", "password": "string" }
- Response:
{ "token": "string" }
- Endpoint:
/api/Account/RefreshToken
- Method: POST
- Request Body:
{ "token": "string" }
- Response:
{ "token": "string" }
- Endpoint:
/api/Account/ChangePassword
- Method: POST
- Request Body:
{ "currentPassword": "string", "newPassword": "string" }
- Response:
{ "message": "Password changed successfully" }
- Endpoint:
/api/Account/LogOut
- Method: POST
- Response:
{ "message": "Logged out successfully" }
- Endpoint:
/api/Admin/CreateRole
- Method: POST
- Request Body:
{ "roleName": "string" }
- Response:
{ "message": "Role created successfully" }
- Endpoint:
/api/Admin/AddRoleToUser
- Method: POST
- Request Body:
{ "userName": "string", "roleName": "string" }
- Response:
{ "message": "Role added to user successfully" }
- Endpoint:
/api/Admin/SendEmail
- Method: POST
- Request Body:
{ "toEmail": "string", "subject": "string", "body": "string", "attachments": ["string"] }
- Response:
{ "message": "Email sent successfully" }
- Endpoint:
/api/Admin/WelcomeEmail
- Method: POST
- Request Body:
{ "userName": "string", "email": "string" }
- Response:
{ "message": "Welcome email sent successfully" }
- Endpoint:
/api/Admin/RemoveRoleFromUser
- Method: POST
- Request Body:
{ "userName": "string", "roleName": "string" }
- Response:
{ "message": "Role removed from user successfully" }
- Endpoint:
/api/Admin/DeleteRole/{roleId}
- Method: DELETE
- Response:
{ "message": "Role deleted successfully" }
- Endpoint:
/api/Admin/DeleteUser
- Method: DELETE
- Request Body:
{ "userId": "string" }
- Response:
{ "message": "User deleted successfully" }
- Endpoint:
/api/Cart/GetCart
- Method: GET
- Response:
{ "items": [ { "productId": "int", "quantity": "int", "price": "decimal" } ] }
- Endpoint:
/api/Cart/RemoveProductFromCart
- Method: DELETE
- Request Body:
{ "productId": "int" }
- Response:
{ "message": "Product removed from cart successfully" }
- Endpoint:
/api/Category/GetAll
- Method: GET
- Response:
[ { "id": "int", "name": "string", "description": "string" } ]
- Endpoint:
/api/Category/GetByID/{id}
- Method: GET
- Response:
{ "id": "int", "name": "string", "description": "string" }
- Endpoint:
/api/Category/GetByName/{name}
- Method: GET
- Response:
{ "id": "int", "name": "string", "description": "string" }
- Endpoint:
/api/Category/AddCategory
- Method: POST
- Request Body:
{ "name": "string", "description": "string" }
- Response:
{ "id": "int", "name": "string", "description": "string" }
- Endpoint:
/api/Category/UpdateCategory
- Method: PUT
- Request Body:
{ "name": "string", "description": "string" }
- Response:
{ "id": "int", "name": "string", "description": "string" }
- Endpoint:
/api/Category/DeleteCategory
- Method: DELETE
- Request Body:
{ "categoryId": "int" }
- Response:
{ "message": "Category deleted successfully" }
- Endpoint:
/api/Product/GetAll
- Method: GET
- Response:
[ { "id": "int", "name": "string", "description": "string", "price": "decimal", "categoryId": "int" } ]
- Endpoint:
/api/Product/GetByID/{id}
- Method: GET
- Response:
{ "id": "int", "name": "string", "description": "string", "price": "decimal", "categoryId": "int" }
- Endpoint:
/api/Product/GetByName
- Method: GET
- Response:
{ "id": "int", "name": "string", "description": "string", "price": "decimal", "categoryId": "int" }
- Endpoint:
/api/Product/AddProduct
- Method: POST
- Request Body:
{ "name": "string", "description": "string", "photo": "string", "price": "decimal", "categoryId": "int" }
- Response:
{ "id": "int", "name": "string", "description": "string", "photo": "string", "price": "decimal", "categoryId": "int" }
- Endpoint:
/api/Product/AddProductToCart
- Method: POST
- Request Body:
{ "productId": "int" }
- Response:
{ "message": "Product added to cart successfully" }
- Endpoint:
/api/Product/UpdateProduct
- Method: PUT
- Request Body:
{ "name": "string", "description": "string", "photo": "string", "price": "decimal", "categoryId": "int" }
- Response:
{ "id": "int", "name": "string", "description": "string", "photo": "string", "price": "decimal", "categoryId": "int" }
- Endpoint:
/api/Product/DeleteProduct
- Method: DELETE
- Request Body:
{ "productId": "int" }
- Response:
{ "message": "Product deleted successfully" }
- Endpoint:
/api/Order/GetAll
- Method: GET
- Response:
[ { "id": "int", "userId": "int", "total": "decimal", "status": "string", "createdDate": "datetime" } ]
- Endpoint:
/api/Order/GetOrderbyID/{id}
- Method: GET
- Response:
{ "id": "int", "userId": "int", "total": "decimal", "status": "string", "createdDate": "datetime" }
- Endpoint:
/api/Order/MakeOrder
- Method: POST
- Request Body:
{ "fullName": "string", "address": "string", "phone": "string" }
- Response:
{ "id": "int", "userId": "int", "total": "decimal", "status": "string", "createdDate": "datetime" }
- Endpoint:
/api/Order/DeleteOrder
- Method: DELETE
- Request Body:
{ "orderId": "int" }
- Response:
{ "message": "Order deleted successfully" }