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 CanteenDataModels.Models; using CanteenContracts.BindingModels; using CanteenContracts.ViewModels; using System.Net; namespace CanteenDatabaseImplement.Models { public class Cook : ICookModel { public int Id { get; private set; } [Required] public string CookFIO { get; private set; } = string.Empty; [Required] public string Email { get; private set; } = string.Empty; [Required] public string Password { get; private set; } = string.Empty; [ForeignKey("CookId")] public virtual List Orders { get; set; } = new(); public static Cook? Create(CookBindingModel model) { if (model == null) { return null; } return new Cook() { Id = model.Id, CookFIO = model.CookFIO, Email = model.Email, Password = model.Password, }; } public void Update(CookBindingModel model) { if (model == null) { return; } CookFIO = model.CookFIO; Email = model.Email; Password = model.Password; } public CookViewModel GetViewModel => new() { Id = Id, CookFIO = CookFIO, Email = Email, Password = Password, }; } }