using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain.Entities.Donations;

public class CrewSessionConsent
{
    [ForeignKey(nameof(CrewSessionID))]
    public virtual CrewSession? CrewSession { get; private set; }

    [ForeignKey(nameof(CrewMemberID))]
    public virtual CrewMember? CrewMember { get; private set; }

    [Key]
    public int ID { get; private set; }

    public int CrewSessionID { get; private set; }

    public int CrewMemberID { get; private set; }

    public bool IsConsented { get; private set; }

    public DateTime? ConsentedAt { get; private set; }

    public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;

    private CrewSessionConsent() { }

    public static CrewSessionConsent Create(int crewSessionID, int crewMemberID)
    {
        return new CrewSessionConsent
        {
            CrewSessionID = crewSessionID,
            CrewMemberID = crewMemberID
        };
    }

    public void Consent()
    {
        IsConsented = true;
        ConsentedAt = DateTime.UtcNow;
    }
}