namespace Domain.Exceptions;

public abstract class DomainException : Exception
{
    public string Code { get; }

    protected DomainException(string code, string message) : base(message)
    {
        Code = code;
    }
}

public class MaxEnrollmentsExceededException : DomainException
{
    public MaxEnrollmentsExceededException(int studentId)
        : base("MAX_ENROLLMENTS", $"Student {studentId} cannot enroll in more than 3 subjects") { }
}

public class SameProfessorConstraintException : DomainException
{
    public SameProfessorConstraintException(int studentId, int professorId)
        : base("SAME_PROFESSOR", $"Student {studentId} already has a subject with professor {professorId}") { }
}

public class StudentNotFoundException : DomainException
{
    public StudentNotFoundException(int studentId)
        : base("STUDENT_NOT_FOUND", $"Student {studentId} was not found") { }
}

public class SubjectNotFoundException : DomainException
{
    public SubjectNotFoundException(int subjectId)
        : base("SUBJECT_NOT_FOUND", $"Subject {subjectId} was not found") { }
}

public class EnrollmentNotFoundException : DomainException
{
    public EnrollmentNotFoundException(int enrollmentId)
        : base("ENROLLMENT_NOT_FOUND", $"Enrollment {enrollmentId} was not found") { }
}

public class DuplicateEnrollmentException : DomainException
{
    public DuplicateEnrollmentException(int studentId, int subjectId)
        : base("DUPLICATE_ENROLLMENT", $"Student {studentId} is already enrolled in subject {subjectId}") { }
}
