REST API for product management built with ASP.NET Core. Supports v1 (classic) and v2 (paginated) endpoints. Uses SQL Server for data storage with Entity Framework Core. Includes unit, integration, and end-to-end tests.
- .NET 10 SDK
- SQL Server (or SQL Server Express)
- Git
git clone <repository-url>
cd alza-api/AlzaApiUpdate the connection string in AlzaApi.App/appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=AlzaDb;Trusted_Connection=True;TrustServerCertificate=True;"
}
}cd AlzaApi.App
dotnet runThe application will automatically apply migrations and seed the database on first run.
Navigate to http://localhost:5000/swagger in your browser.
Two API versions are available:
- V1 — Classic endpoints (get all, get by id, update description)
- V2 — Paginated endpoints
Set UseMockData to true in appsettings.json:
{
"UseMockData": true
}This uses in-memory seed data instead of SQL Server.
No database required — uses Moq.
cd AlzaApi.BL.UnitTests
dotnet testRequires a SQL Server instance. Create appsettings.Test.json in AlzaApi.DAL.IntegrationTests/:
{
"ConnectionStrings": {
"TestConnection": "Server=YOUR_SERVER;Database=AlzaDb_Test;Trusted_Connection=True;TrustServerCertificate=True;"
}
}Then run:
cd AlzaApi.DAL.IntegrationTests
dotnet testRequires a SQL Server instance. Create appsettings.Test.json in AlzaApi.App.EndToEndTests/:
{
"ConnectionStrings": {
"TestConnection": "Server=YOUR_SERVER;Database=AlzaDb_Test;Trusted_Connection=True;TrustServerCertificate=True;"
}
}Then run:
cd AlzaApi.App.EndToEndTests
dotnet testNote:
appsettings.Test.jsonfiles are excluded from version control. Create them locally before running tests.
dotnet testAlzaApi/
├── AlzaApi.App/ # ASP.NET Core application, controllers, middleware
├── AlzaApi.BL/ # Business logic layer, services
├── AlzaApi.DAL/ # Data access layer, repositories, migrations
├── AlzaApi.Common/ # Shared DTOs, models, exceptions
├── AlzaApi.BL.UnitTests/ # Unit tests for BL layer (Moq)
├── AlzaApi.DAL.IntegrationTests/ # Integration tests for DAL layer
└── AlzaApi.App.EndToEndTests/ # End-to-end tests for API endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/products |
Get all products |
| GET | /api/v1/products/{id} |
Get product by ID |
| PATCH | /api/v1/products/{id}/description |
Update product description |
| GET | /api/v2/products |
Get paginated products |