ProjectDefense is a booking system for project defense time slots in university labs — a web application (Razor Pages + Minimal API), a domain layer, an application layer, and a simple console client. The project includes authentication/authorization (Identity), automatic slot generation based on lecturer availability, student self‑booking, and exporting reservation lists.
- Requirements
- Quick start (local)
- Configuration
- Build and run
- Project architecture
- API (Minimal Endpoints)
- Models and DTOs
- Database and migrations
- UI and Pages (Razor)
- Console client
- Data export
- .NET 9 SDK (the project targets
net9.0) - (Optional) Visual Studio 2022/2023, Rider, or another .NET‑capable IDE
- SQLite (the repository includes a default
ProjectDefense.dbfile)
- Clone the repository:
git clone <repo-url>
cd ProjectDefense- Restore dependencies and build the solution:
dotnet restore
dotnet build- Run the web application (the
ProjectDefenseproject under theProjectDefensefolder):
dotnet run --project ProjectDefense\ProjectDefense.Web.csprojSwagger (Development only) is enabled by default when the app runs in Development.
Main settings live in ProjectDefense/appsettings.json and appsettings.Development.json.
- ConnectionStrings:
DefaultConnectionis set toData Source=ProjectDefense.db(SQLite) by default. - MailGun: email delivery configuration (used by
IEmailService) — consider storing production secrets in user‑secrets or environment variables. - ASPNETCORE_ENVIRONMENT:
Development/Production— affects Swagger, error pages, and data seeding.
- Build (Release):
dotnet publish ProjectDefense\ProjectDefense.Web.csproj -c Release -o ./publish- Run in Development (see Quick start above).
The solution is split into layers:
ProjectDefense.Web– web app (Razor Pages), middleware, DI configuration, minimal API endpoints.ProjectDefense.Application– application logic: DTOs, repository interfaces, use cases (commands & queries), validators.ProjectDefense.Domain– domain entities (User,Room,LecturerAvailability,Reservation,StudentBlock).ProjectDefense.Infrastructure– repository implementations,ApplicationDbContext(Identity + EF Core), migrations, and services (Email, Export).ProjectDefense.ConsoleApp– a simple console client that calls the API.
A broader requirements overview is available in ProjectDefense/architecture.md.
Minimal endpoints are defined in ProjectDefense/Api/SlotsController.cs:
-
GET /api/slots/available
- Returns a list of available slots:
AvailableReservationDto(Id, StartTime, EndTime, RoomName, RoomNumber)
- Returns a list of available slots:
-
GET /api/rooms
- Returns a list of rooms:
RoomDto(Id, Name, Number)
- Returns a list of rooms:
-
POST /api/slots/{id}/book
- Books a slot with the specified
id. Request body:BookReservationDto{ StudentIndex } - May return 200 OK or 404 NotFound
- Books a slot with the specified
Example calls (curl):
curl http://localhost:5172/api/slots/available
curl -X POST http://localhost:5172/api/slots/123/book \
-H "Content-Type: application/json" \
-d '{"studentIndex":"s12345"}'Note: Authentication and roles are configured through Identity; not all endpoints must be exposed in the UI.
Key DTOs live in ProjectDefense.Application/DTOs:
AvailableReservationDto– simple DTO for available slots.BookReservationDto– request model for booking (StudentIndex).ReservationDto– a richer reservation DTO with student and timing info.RoomDto– room DTO.
Domain entities (short):
User(inheritsIdentityUser) – extraRolefield.Room– Id, Name, Number.LecturerAvailability– lecturer availability definition (StartDate, EndDate, RoomId, SlotDurationInMinutes) and generatedReservationlist.Reservation– StartTime, EndTime, AvailabilityId, StudentId, IsBlocked.StudentBlock– temporarily or permanently blocks students.
The project uses EF Core with SQLite via the default connection string Data Source=ProjectDefense.db.
Migrations are in ProjectDefense.Infrastructure/Migrations (e.g., 20251115141711_InitialCreate).
On startup, the app runs migrations automatically (see Program.cs and dbContext.Database.MigrateAsync()).
To run migrations manually:
# from the solution root
dotnet ef database update \
--project ProjectDefense\ProjectDefense.Infrastructure\ProjectDefense.Infrastructure.csproj \
--startup-project ProjectDefense\ProjectDefense.Web.csprojRazor Pages reside under ProjectDefense/Pages. There are dedicated areas/views for Student and Lecturer roles, and Identity pages live under Areas/Identity.
Main local routes:
- Home:
/(Index) - Student panel:
/Student(list of available slots) - Lecturer panel:
/Lecturer(manage rooms, availability, export)
ProjectDefense.ConsoleApp is a simple client that issues HTTP calls to the minimal API (e.g., fetch available slots and book).
Run:
dotnet run --project ProjectDefense\ProjectDefense.ConsoleApp\ProjectDefense.ConsoleApp.csprojThe infrastructure layer includes an ExportService that can export reservations to .txt, .xlsx (ClosedXML), and .pdf (QuestPDF). Usage is exposed in the Lecturer UI (Export page).