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.Diagnostics; using System.Linq; using System.Runtime.ConstrainedExecution; using System.Text; using System.Threading.Tasks; namespace SchoolAgainStudyDataBaseImplements.Models { public class Student : IStudent { [Required] public string Name { get; set; } = string.Empty; [Required] public int Class { get; set; } [Required] public string Email { 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("StudentId")] public virtual List Interests { get; set; } = new(); [ForeignKey("StudentId")] public virtual List Diys { get; set; } = new(); [ForeignKey("StudentId")] public virtual List Products { get; set; } = new(); public static Student Create(SchoolDataBase context, StudentBindingModel model) { return new Student() { Id = model.Id, Name = model.Name, Class = model.Class, Email = model.Email, Login = model.Login, Password = model.Password, }; } public void Update(StudentBindingModel model) { Name = model.Name; Class = model.Class; Email = model.Email; Login = model.Login; Password = model.Password; } public StudentViewModel GetViewModel => new() { Id = Id, Name = Name, Class = Class, Email = Email, Login = Login, Password = Password }; } }