using SolutionErp.Domain.Common;

namespace SolutionErp.Domain.Office;

// Phase 10.2 G-O2 (Mig 36 — S36) — Booking phòng họp.
// Overlap check qua SERIALIZABLE tx + EXISTS query trong handler
// (NOT DB constraint vì datetime range not native SQL Server).
// Reference NamGroup TblBookingResource S50 — SOL adapt 3-state status.
public class MeetingBooking : AuditableEntity
{
    public Guid RoomId { get; set; }
    public MeetingRoom Room { get; set; } = null!;        // FK Restrict — không xoá Room còn booking active

    public Guid BookedByUserId { get; set; }              // User đặt phòng (Creator semantics)
    public string BookedByFullName { get; set; } = string.Empty;  // denorm tránh cascade

    public DateTime StartAt { get; set; }                 // UTC datetime2
    public DateTime EndAt { get; set; }                   // UTC datetime2. EndAt > StartAt (validator)

    public string Title { get; set; } = string.Empty;     // "Họp giao ban tuần", "Phỏng vấn ứng viên"
    public string? Description { get; set; }              // Nội dung chi tiết / agenda

    public MeetingBookingStatus Status { get; set; } = MeetingBookingStatus.Confirmed;

    public string? Note { get; set; }                     // Ghi chú thêm (vd "Cần chuẩn bị nước uống")

    // Attendees nav — collection join entity (NOT JSON, theo Investigator verdict S36)
    public List<MeetingBookingAttendee> Attendees { get; set; } = new();
}
