PIbd-21_Pyatakov_KM_Markov_.../UniversityDataBaseImplemet/Models/EducationStatus.cs

51 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityContracts.BindingModels;
using UniversityContracts.ViewModels;
using UniversityModels.Models;
namespace UniversityDataBaseImplemet.Models
{
public class EducationStatus : IEducationStatusModel
{
public int Id { get; private set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public int UserId { get; set; }
[ForeignKey("EducationStatusId")]
public virtual List<Student> Students { get; set; } = new();
2023-04-08 13:59:34 +04:00
public virtual User User { get; set; }
public static EducationStatus? Create(EducationStatusBindingModel model)
{
return new EducationStatus()
{
Id = model.Id,
Name = model.Name,
UserId = model.UserId,
};
}
public void Update(EducationStatusBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
UserId = model.UserId;
}
public EducationStatusViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
UserId = UserId,
};
}
}