Danil Markov
96a6d6bbf7
Почти сделан pdf (добавил вспомогательный viewmodel так как C# не умеет в кортежи). Нужно доделать pdf с отправкой на почту и навести красоту (стили, валидацию)
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.ComponentModel.DataAnnotations.Schema;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using UniversityContracts.BindingModels;
|
||
using UniversityContracts.ViewModels;
|
||
using UniversityModels.Models;
|
||
|
||
namespace UniversityDataBaseImplemet.Models
|
||
{
|
||
public class Student : IStudentModel
|
||
{
|
||
public int Id { get; private set; }
|
||
[Required]
|
||
public string Name { get; set; } = string.Empty;
|
||
[Required]
|
||
public string Surname { get; set; } = string.Empty;
|
||
[Required]
|
||
public DateTime DateOfBirth { get; set; }
|
||
[Required]
|
||
public DateTime DateOfAddmission { get; set; }
|
||
[Required]
|
||
public int StudentCard { get; set; }
|
||
|
||
public int? EducationStatusId { get; set; }
|
||
[Required]
|
||
public int UserId { get; set; }
|
||
[ForeignKey("StudentId")]
|
||
public virtual List<StudentDocument> DocumentStudents { get; set; } = new();
|
||
[ForeignKey("StudentId")]
|
||
public virtual List<StudentStream> StudentStream { get; set; } = new();
|
||
public virtual EducationStatus? EducationStatus { get; set; }
|
||
public virtual User User { get; set; }
|
||
|
||
public static Student Create(StudentBindingModel model)
|
||
{
|
||
return new Student()
|
||
{
|
||
Id = model.Id,
|
||
Name = model.Name,
|
||
Surname = model.Surname,
|
||
DateOfBirth = model.DateOfBirth,
|
||
DateOfAddmission = model.DateOfAddmission,
|
||
StudentCard = model.StudentCard,
|
||
EducationStatusId = model.EducationStatusId,
|
||
UserId = model.UserId
|
||
};
|
||
}
|
||
public void Update(StudentBindingModel model)
|
||
{
|
||
Name = model.Name;
|
||
Surname = model.Surname;
|
||
DateOfBirth = model.DateOfBirth;
|
||
DateOfAddmission = model.DateOfAddmission;
|
||
StudentCard = model.StudentCard;
|
||
EducationStatusId = model.EducationStatusId;
|
||
}
|
||
public StudentViewModel GetViewModel => new()
|
||
{
|
||
Id = Id,
|
||
Name = Name,
|
||
Surname = Surname,
|
||
DateOfBirth = DateOfBirth,
|
||
DateOfAddmission = DateOfAddmission,
|
||
StudentCard = StudentCard,
|
||
EducationStatusId = EducationStatusId,
|
||
UserId = UserId,
|
||
EducationStatusName = EducationStatus?.Name ?? "Не указан"
|
||
};
|
||
}
|
||
}
|