using SchoolAgainStudyContracts.BindingModel; using SchoolAgainStudyContracts.ViewModel; using SchoolAgainStudyDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Security.Claims; using System.Text; using System.Threading.Tasks; namespace SchoolAgainStudyDataBaseImplements.Models { public class Teacher : ITeacher { [Required] public string Name { get; set; } = string.Empty; [Required] public string Post { get; set; } = string.Empty; [Required] public string Phone { get; set; } = string.Empty; [Required] public string Login { get; set; } = string.Empty; [Required] public string Password { get; set; } = string.Empty; public int Id { get; set; } [ForeignKey("TeacherId")] public virtual List Materials { get; set; } = new(); [ForeignKey("TeacherId")] public virtual List Tasks { get; set; } = new(); [ForeignKey("TeacherId")] public virtual List Lessons { get; set; } = new(); public static Teacher Create(SchoolDataBase context, TeacherBindingModel model) { return new Teacher() { Id = model.Id, Name = model.Name, Post = model.Post, Phone = model.Phone, Login = model.Login, Password = model.Password, }; } public void Update(TeacherBindingModel model) { Name = model.Name; Post = model.Post; Phone = model.Phone; Login = model.Login; Password = model.Password; } public TeacherViewModel GetViewModel => new() { Id = Id, Name = Name, Post = Post, Phone = Phone, Login = Login, Password = Password, }; } }