01 路 Model
Four related entities
Property, Tenant, Lease and Payment, related through EF Core. Deleting a property or tenant that
has leases is restricted, payments cascade from their lease, and money columns are fixed at decimal(12,2).
02 路 Contracts
DTOs for every operation
Separate create, update and response DTOs per entity keep the database model out of the API surface. Read endpoints use
AsNoTracking and project straight into response DTOs.
03 路 Rules
Business rules in the controllers
A lease is rejected if the property or tenant does not exist, the property already has an active lease or is unavailable, or the end date is not after
the start date. Creating a lease marks the property unavailable and deleting it frees the property again. A payment needs an existing lease and an amount above zero.
04 路 Reporting
One dashboard summary endpoint
GET /api/Dashboard/summary returns total, occupied and available properties, the occupancy rate, active leases, monthly rental income,
payments received this month and outstanding payments, using aggregate queries on the database.