2024-04-24 14:57:31 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UniversityContracts.BindingModels;
|
|
|
|
|
using UniversityContracts.ViewModels;
|
|
|
|
|
using UniversityDataModels.Enums;
|
|
|
|
|
using UniversityDataModels.Models;
|
|
|
|
|
|
|
|
|
|
namespace UniversityDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Attestation : IAttestationModel
|
2024-04-24 14:08:27 +04:00
|
|
|
|
{
|
2024-04-24 14:57:31 +04:00
|
|
|
|
public int Id { get; private set; }
|
2024-04-29 22:15:15 +04:00
|
|
|
|
[Required]
|
2024-04-29 19:06:11 +04:00
|
|
|
|
public int UserId { get; private set; }
|
2024-04-29 22:15:15 +04:00
|
|
|
|
[Required]
|
2024-04-24 14:57:31 +04:00
|
|
|
|
public int StudentId { get; private set; }
|
2024-05-28 00:44:23 +04:00
|
|
|
|
public string StudentName { get; private set; } = string.Empty;
|
2024-04-24 14:57:31 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public string FormOfEvaluation { get; private set; } = string.Empty;
|
|
|
|
|
[Required]
|
|
|
|
|
public AttestationScore Score { get; private set; } = AttestationScore.Неявка;
|
|
|
|
|
public virtual Student Student { get; set; } = new();
|
2024-04-29 19:06:11 +04:00
|
|
|
|
public virtual User User { get; set; } = new();
|
|
|
|
|
public static Attestation? Create(UniversityDatabase context, AttestationBindingModel model)
|
2024-04-24 14:08:27 +04:00
|
|
|
|
{
|
2024-04-24 14:57:31 +04:00
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Attestation()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
2024-04-29 19:06:11 +04:00
|
|
|
|
UserId = model.UserId,
|
|
|
|
|
User = context.Users.First(x => x.Id == model.UserId),
|
2024-04-24 14:57:31 +04:00
|
|
|
|
StudentId = model.StudentId,
|
2024-04-29 19:06:11 +04:00
|
|
|
|
Student = context.Students.First(x => x.Id == model.StudentId),
|
2024-05-28 00:44:23 +04:00
|
|
|
|
StudentName = model.StudentName,
|
2024-04-24 14:57:31 +04:00
|
|
|
|
FormOfEvaluation = model.FormOfEvaluation,
|
|
|
|
|
Score = model.Score
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(AttestationBindingModel model)
|
2024-04-24 14:08:27 +04:00
|
|
|
|
{
|
2024-04-24 14:57:31 +04:00
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
StudentId = model.StudentId;
|
2024-05-28 00:44:23 +04:00
|
|
|
|
StudentName = model.StudentName;
|
2024-04-24 14:57:31 +04:00
|
|
|
|
FormOfEvaluation = model.FormOfEvaluation;
|
|
|
|
|
Score = model.Score;
|
2024-04-24 14:08:27 +04:00
|
|
|
|
}
|
2024-04-24 14:57:31 +04:00
|
|
|
|
public AttestationViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
StudentId = StudentId,
|
2024-05-28 00:44:23 +04:00
|
|
|
|
StudentName = StudentName,
|
2024-04-24 14:57:31 +04:00
|
|
|
|
FormOfEvaluation = FormOfEvaluation,
|
|
|
|
|
Score = Score
|
|
|
|
|
};
|
2024-04-24 14:08:27 +04:00
|
|
|
|
}
|
2024-04-24 14:57:31 +04:00
|
|
|
|
}
|