feat(domain): add core entities — Club, Member, WorkItem, Shift with state machine
- Create domain entities in WorkClub.Domain/Entities: Club, Member, WorkItem, Shift, ShiftSignup
- Implement enums: SportType, ClubRole, WorkItemStatus
- Add ITenantEntity interface for multi-tenancy support
- Implement state machine validation on WorkItem with C# 14 switch expressions
- Valid transitions: Open→Assigned→InProgress→Review→Done, Review→InProgress (rework)
- All invalid transitions throw InvalidOperationException
- TDD approach: Write tests first, 12/12 passing
- Use required properties with explicit Guid/Guid? for foreign keys
- DateTimeOffset for timestamps (timezone-aware, multi-tenant friendly)
- RowVersion byte[] for optimistic concurrency control
- No navigation properties yet (deferred to EF Core task)
- No domain events or validation attributes (YAGNI for MVP)
2026-03-03 14:09:25 +01:00
|
|
|
using WorkClub.Domain.Enums;
|
|
|
|
|
using WorkClub.Domain.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace WorkClub.Domain.Entities;
|
|
|
|
|
|
|
|
|
|
public class WorkItem : ITenantEntity
|
|
|
|
|
{
|
|
|
|
|
public required Guid Id { get; set; }
|
|
|
|
|
public required string TenantId { get; set; }
|
|
|
|
|
public required string Title { get; set; }
|
|
|
|
|
public string? Description { get; set; }
|
|
|
|
|
public required WorkItemStatus Status { get; set; }
|
|
|
|
|
public Guid? AssigneeId { get; set; }
|
|
|
|
|
public required Guid CreatedById { get; set; }
|
|
|
|
|
public required Guid ClubId { get; set; }
|
|
|
|
|
public DateTimeOffset? DueDate { get; set; }
|
|
|
|
|
public required DateTimeOffset CreatedAt { get; set; }
|
|
|
|
|
public required DateTimeOffset UpdatedAt { get; set; }
|
feat(backend): add PostgreSQL schema, RLS policies, and multi-tenant middleware
- Add EF Core migrations for initial schema (clubs, members, work_items, shifts, shift_signups)
- Implement RLS policies with SET LOCAL for tenant isolation
- Add Finbuckle multi-tenant middleware with ClaimStrategy + HeaderStrategy fallback
- Create TenantValidationMiddleware to enforce JWT claims match X-Tenant-Id header
- Add tenant-aware DB interceptors (SaveChangesTenantInterceptor, TenantDbConnectionInterceptor)
- Configure AppDbContext with tenant scoping and RLS support
- Add test infrastructure: CustomWebApplicationFactory, TestAuthHandler, DatabaseFixture
- Write TDD integration tests for multi-tenant isolation and RLS enforcement
- Add health check null safety for connection string
Tasks: 7 (PostgreSQL schema + migrations + RLS), 8 (Finbuckle multi-tenancy + validation), 12 (test infrastructure)
2026-03-03 14:32:21 +01:00
|
|
|
public uint RowVersion { get; set; }
|
feat(domain): add core entities — Club, Member, WorkItem, Shift with state machine
- Create domain entities in WorkClub.Domain/Entities: Club, Member, WorkItem, Shift, ShiftSignup
- Implement enums: SportType, ClubRole, WorkItemStatus
- Add ITenantEntity interface for multi-tenancy support
- Implement state machine validation on WorkItem with C# 14 switch expressions
- Valid transitions: Open→Assigned→InProgress→Review→Done, Review→InProgress (rework)
- All invalid transitions throw InvalidOperationException
- TDD approach: Write tests first, 12/12 passing
- Use required properties with explicit Guid/Guid? for foreign keys
- DateTimeOffset for timestamps (timezone-aware, multi-tenant friendly)
- RowVersion byte[] for optimistic concurrency control
- No navigation properties yet (deferred to EF Core task)
- No domain events or validation attributes (YAGNI for MVP)
2026-03-03 14:09:25 +01:00
|
|
|
|
|
|
|
|
public bool CanTransitionTo(WorkItemStatus newStatus) => (Status, newStatus) switch
|
|
|
|
|
{
|
|
|
|
|
(WorkItemStatus.Open, WorkItemStatus.Assigned) => true,
|
|
|
|
|
(WorkItemStatus.Assigned, WorkItemStatus.InProgress) => true,
|
|
|
|
|
(WorkItemStatus.InProgress, WorkItemStatus.Review) => true,
|
|
|
|
|
(WorkItemStatus.Review, WorkItemStatus.Done) => true,
|
|
|
|
|
(WorkItemStatus.Review, WorkItemStatus.InProgress) => true,
|
|
|
|
|
_ => false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public void TransitionTo(WorkItemStatus newStatus)
|
|
|
|
|
{
|
|
|
|
|
if (!CanTransitionTo(newStatus))
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException(
|
|
|
|
|
$"Cannot transition from {Status} to {newStatus}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Status = newStatus;
|
|
|
|
|
}
|
|
|
|
|
}
|