A scalable and production-ready ASP.NET Core Web API for managing Paying Guest (PG) accommodations. Built using clean architecture principles with Repository Pattern, Service Layer, DTOs, AutoMapper, and centralized exception handling.
- ✅ CRUD operations for PG listings
- ✅ Clean Architecture (Controller → Service → Repository → DbContext)
- ✅ Repository Pattern implementation
- ✅ DTO-based data transfer
- ✅ AutoMapper for object mapping
- ✅ Global Exception Handling Middleware
- ✅ Entity Framework Core integration
- ✅ Asynchronous programming (async/await)
- ✅ Scalable and maintainable code structure
- ASP.NET Core Web API
- C#
- Entity Framework Core
- SQL Server
- AutoMapper
Controllers/
Services/
Repositories/
Entities/
DTOs/
Mapping/
Exceptions/
Middleware/
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/pg | Get all PGs |
| GET | /api/pg/{id} | Get PG by ID |
| POST | /api/pg | Create PG |
| PUT | /api/pg/{id} | Update PG |
| DELETE | /api/pg/{id} | Delete PG |
- Clone the repository
git clone https://github.com/your-username/StayEase-API.git
- Navigate to project folder
cd StayEase-API
- Restore dependencies
dotnet restore
-
Update connection string in
appsettings.json -
Run migrations
dotnet ef database update
- Run the application
dotnet run
POST /api/pg
Content-Type: application/json
{
"name": "Sunrise PG",
"description": "Comfortable stay with all amenities",
"location": "Bangalore",
"contact": "9876543210",
"owner": "Ravi"
}
- Clean separation of concerns
- Industry-standard architecture
- Easy to extend and maintain
- Production-ready error handling
- 🔍 Search & filtering (location-based)
- 📄 Pagination & sorting
- 🔐 Authentication & Authorization (JWT)
- 📊 Logging & monitoring
Tapan Ray Software Engineer