A full-stack application for managing workers and their work shifts, built with ASP.NET Core Web API and a Console UI using Spectre.Console.
Shifts Logger is a comprehensive solution for tracking worker shifts with full CRUD operations for both workers and their associated shifts. The application consists of two main components:
- ShiftsLogger.API: RESTful API backend with Entity Framework Core and SQL Server
- ShiftsLogger.UI: Interactive console-based user interface
- ✅ Create new workers
- ✅ View all workers
- ✅ View individual worker details with shifts
- ✅ Update worker information
- ✅ Delete workers (cascade deletes associated shifts)
- ✅ Add shifts for workers
- ✅ View all shifts for a specific worker
- ✅ Update shift times
- ✅ Delete shifts
- ✅ Client-side validation for shift times
- .NET 10.0
- ASP.NET Core Web API
- Entity Framework Core 10.0
- SQL Server
- Swagger/OpenAPI for API documentation
- .NET 10.0
- Spectre.Console for interactive terminal UI
- HttpClient for API communication
STUDY.Console.ShiftsLogger/
├── ShiftsLogger.API/
│ ├── Controllers/
│ │ ├── WorkerController.cs
│ │ └── ShiftController.cs
│ ├── Services/
│ │ ├── WorkerService.cs
│ │ └── ShiftService.cs
│ ├── Models/
│ │ ├── Worker.cs
│ │ ├── Shift.cs
│ │ └── DTOs/
│ ├── Data/
│ │ └── AppDbContext.cs
│ ├── Migrations/
│ └── Program.cs
├── ShiftsLogger.UI/
│ ├── Controller/
│ │ ├── WorkerController.cs
│ │ └── ShiftsController.cs
│ ├── Services/
│ │ ├── WorkerService.cs
│ │ └── ShiftService.cs
│ ├── DTOs/
│ ├── Configuration.cs
│ ├── UserInterface.cs
│ └── Program.cs
└── README.md
- .NET 10.0 SDK
- SQL Server (LocalDB, Express, or Full)
- A terminal that supports ANSI colors (for UI)
git clone <repository-url>
cd STUDY.Console.ShiftsLogger/STUDY.Console.ShiftsLoggerUpdate the connection string in ShiftsLogger.API/appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=ShiftLogger;user id=YOUR_USER;password=YOUR_PASSWORD;Encrypt=true;TrustServerCertificate=true;"
}
}cd ShiftsLogger.API
dotnet ef database updatecd ShiftsLogger.API
dotnet runThe API will start at http://localhost:5298
If your API runs on a different port, update ShiftsLogger.UI/Configuration.cs:
public const string ApiUrl = "http://localhost:YOUR_PORT/api";Open a new terminal:
cd ShiftsLogger.UI
dotnet run| Method | Endpoint | Description |
|---|---|---|
| GET | /api/Worker |
Get all workers |
| GET | /api/Worker/{id} |
Get worker by ID |
| GET | /api/Worker/{id}/Details |
Get worker with all shifts |
| POST | /api/Worker |
Create new worker |
| PUT | /api/Worker/{id} |
Update worker |
| DELETE | /api/Worker/{id} |
Delete worker |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/Shift/{id} |
Get shift by ID |
| POST | /api/Shift |
Create new shift |
| PUT | /api/Shift/{id} |
Update shift |
| DELETE | /api/Shift/{id} |
Delete shift |
When the API is running in Development mode, access Swagger UI at:
http://localhost:5298/swagger
curl -X POST http://localhost:5298/api/Worker \
-H "Content-Type: application/json" \
-d '{"name":"John Doe"}'curl -X POST http://localhost:5298/api/Shift \
-H "Content-Type: application/json" \
-d '{
"startTime":"2026-02-12T09:00:00Z",
"endTime":"2026-02-12T17:00:00Z",
"workerId":1
}'- Main Menu: View workers, add new workers, or exit
- Worker Management: Update worker, delete worker, or manage shifts
- Shift Management: Add, update, or delete shifts for selected worker
Id(int, PK, Identity)Name(nvarchar(100), Required)
Id(int, PK, Identity)StartTime(datetimeoffset, Required)EndTime(datetimeoffset, Required)WorkerId(int, FK, Nullable)
Relationship: One Worker → Many Shifts (Cascade Delete)
- ✅ Fixed HttpClient socket exhaustion using static readonly instances
- ✅ Removed circular dependency between WorkerService and ShiftService
- ✅ Fixed return type mismatch in WorkerController
- ✅ Added model validation attributes
- ✅ Improved query efficiency in GetWorkerWithShiftsAsync
- ✅ Fixed URL consistency in service calls
This is a study project from The C# Academy. Feel free to fork and experiment!