Shop.Api is a RESTful Web API built with ASP.NET Core and .NET 11.
It provides endpoints for managing product categories, products, and inventory in an e-commerce system.
- Category management
- Product management
- Inventory management
- Input validation and centralized exception handling
- SQL Server integration using ADO.NET
- Framework: ASP.NET Core 11
- Language: C# 14
- Database: Microsoft SQL Server
- Data Access: ADO.NET (
Microsoft.Data.SqlClient) - API Architecture: Controllers, Services, and Repositories
- API Documentation: OpenAPI
Before running the project, make sure you have installed:
- .NET 11 SDK
- Microsoft SQL Server
- A SQL Server client (e.g. DbGate)
-
Make sure Microsoft SQL Server is running.
-
Create the Database Schema:
Run the SQL script located at:
Shop.Api/Database/schema.sql
This script creates the Shop database, including all tables, constraints, and foreign key relationships.
The database contains the following tables:
CategoriesProductsInventory
The application uses the DefaultConnection connection string to connect to SQL Server.
For local development, configure it using .NET User Secrets:
-
Initialize User Secrets:
dotnet user-secrets init
-
Set the connection string:
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Server=localhost;Database=Shop;User Id=YOUR_USER_NAME;Password=YOUR_PASSWORD;TrustServerCertificate=True"
Replace YOUR_USER_NAME and YOUR_PASSWORD with your SQL Server password.
Note: Never commit database credentials or secrets to source control.
-
Clone the repository:
git clone YOUR_REPOSITORY_URL
-
Navigate to the project directory:
cd Shop.Api -
Restore dependencies:
dotnet restore
-
Build the project:
dotnet build
-
Run the application:
dotnet run
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/Categories |
Get all categories |
| GET | /api/Categories/{id} |
Get a category by ID |
| POST | /api/Categories |
Create a category |
| PUT | /api/Categories/{id} |
Update a category |
| DELETE | /api/Categories/{id} |
Delete a category |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/Products |
Get all products |
| GET | /api/Products/{id} |
Get a product by ID |
| POST | /api/Products |
Create a product |
| PUT | /api/Products/{id} |
Update a product |
| DELETE | /api/Products/{id} |
Delete a product |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/Inventory/{productId} |
Get inventory for a product |
| POST | /api/Inventory |
Create inventory |
| PUT | /api/Inventory/{productId} |
Update inventory |
| DELETE | /api/Inventory/{productId} |
Delete inventory |