using SchoolScheduleContracts.BindingModels; using SchoolScheduleContracts.ViewModels; using SchoolScheduleDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SchoolScheduleDataBaseImplement.Models { public class Teacher : ITeacherModel { public int Id { get; private set; } [Required] public string FullName { get; private set; } = string.Empty; [ForeignKey("TeacherId")] public virtual List Lessons { get; set; } = new(); [ForeignKey("TeacherId")] public virtual List Grade { get; set; } = new(); public static Teacher Create(SchoolScheduleDataBase context, TeacherBindingModel model) { return new Teacher() { Id = model.Id, FullName = model.FullName }; } public void Update(SchoolScheduleDataBase context, TeacherBindingModel model) { FullName = model.FullName; } public TeacherViewModel GetViewModel => new() { Id = Id, FullName = FullName, }; } }