Files
2025-04-12 17:07:29 +04:00

62 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityAllExpelled_Models.Enums;
using UniversityAllExpelled_Models.Exceptions;
using UniversityAllExpelled_Models.Extensions;
using UniversityAllExpelled_Models.Infrostructure;
namespace UniversityAllExpelled_Models.DataModels.Client;
public class StudentDataModel(string id, string userId, FacultyType faculty, GroopType groop, int course) : IValidation
{
public string Id { get; private set; } = id;
public string UserId { get; private set; } = userId;
public FacultyType Faculty { get; private set; } = faculty;
public GroopType Groop { get; private set; } = groop;
public int Course { get; private set; } = course;
public void Validate()
{
if (Id.IsEmpty())
{
throw new ValidationException("Field Id is empty.");
}
if (!Id.IsGuid())
{
throw new ValidationException("The value in field Id is not a valid GUID.");
}
if (UserId.IsEmpty())
{
throw new ValidationException("Field UserId is empty.");
}
if (!UserId.IsGuid())
{
throw new ValidationException("The value in field UserId is not a valid GUID.");
}
if (Faculty == FacultyType.None)
{
throw new ValidationException("Faculty must be specified (cannot be None).");
}
if (Groop == GroopType.None)
{
throw new ValidationException("Group must be specified (cannot be None).");
}
// Проверка Course (должен быть от 1 до 6)
if (Course < 1 || Course > 6)
{
throw new ValidationException("Course must be between 1 and 6.");
}
}
}