A RESTful API for managing walking trails in New Zealand, built with ASP.NET Core and Entity Framework Core.
This project follows Clean Architecture principles with the following layers:
- API Layer: Controllers and DTOs for handling HTTP requests
- Domain Layer: Core business entities and models
- Data Layer: Entity Framework Core with Repository pattern
- Infrastructure: Database context and configurations
- CRUD operations for Walks, Regions, and Difficulties
- Filtering and sorting capabilities
- Model validation with Data Annotations
- Repository pattern implementation
- Async/await throughout
- Entity Framework Core with SQL Server
- Framework: ASP.NET Core 8.0
- Database: SQL Server
- ORM: Entity Framework Core
- Language: C# 12
- Architecture: Repository Pattern + Clean Architecture
- .NET 8.0 SDK
- SQL Server (LocalDB or full instance)
- Visual Studio 2022 or JetBrains Rider
git clone https://github.com/Sonseldeep/Walk.Api
cd Walk.Api{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=NZWalksDb;Trusted_Connection=true;MultipleActiveResultSets=true"
}
}
dotnet ef database update dotnet run --project NZWalks.Api###Regions
GET /api/regions - Get all regions
GET /api/regions/{id} - Get region by ID
POST /api/regions - Create new region
PUT /api/regions/{id} - Update region
DELETE /api/regions/{id} - Delete region
GET /api/walks - Get all walks (supports filtering & sorting)
GET /api/walks/{id} - Get walk by ID
POST /api/walks - Create new walk
PUT /api/walks/{id} - Update walk
DELETE /api/walks/{id} - Delete walkfilterOn=Name&filterQuery=searchterm - Filter by name
sortBy=Name&isAscending=true - Sort by name
sortBy=Length&isAscending=false - Sort by lengthdotnet restore# Entity Framework Core packages
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools
dotnet add package Microsoft.EntityFrameworkCore.Design
# ASP.NET Core packages
dotnet add package Microsoft.AspNetCore.OpenApi
dotnet add package Swashbuckle.AspNetCore# Create initial migration (if not exists)
dotnet ef migrations add InitialCreate
# Update database with migrations
dotnet ef database updatedotnet run --project NZWalks.Apidotnet clean
dotner build
# Rub with specific environment
dotnet run --environment Development
# Watch for changes (hot reload)
dotnet watcg run --project NZWalks.Apidotnet test