using SportsDivision.Domain.Enums;

namespace SportsDivision.Domain.Entities;

public class Student
{
    public int StudentId { get; set; }
    public string ExistingStudentId { get; set; } = string.Empty;
    public string FirstName { get; set; } = string.Empty;
    public string LastName { get; set; } = string.Empty;
    public DateOnly DateOfBirth { get; set; }
    public Sex Sex { get; set; }
    public int SchoolId { get; set; }
    public bool IsActive { get; set; } = true;
    public School School { get; set; } = null!;
    public ICollection<EventRegistration> Registrations { get; set; } = new List<EventRegistration>();

    public int GetAge(DateOnly referenceDate)
    {
        var age = referenceDate.Year - DateOfBirth.Year;
        if (DateOfBirth > referenceDate.AddYears(-age))
            age--;
        return age;
    }

    public string FullName => $"{FirstName} {LastName}";
}
