using CanteenContracts.BindingModels; using CanteenContracts.BusinessLogicsContracts; using CanteenContracts.View; using CanteenDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; using static NHibernate.Engine.Query.CallableParser; namespace CanteenDatabaseImplement.Models { public class Manager : IManagerModel { [Required] public string FIO { get; private set; } = string.Empty; [Required] public string Login { get; private set; } = string.Empty; [Required] public string Password { get; private set; } = string.Empty; [Required] public string PhoneNumber { get; private set; } = string.Empty; public int Id { get; private set; } [ForeignKey("ManagerId")] public virtual List Cooks { get; set; } = new(); [ForeignKey("ManagerId")] public virtual List Products { get; set; } = new(); [ForeignKey("ManagerId")] public virtual List Dishes { get; set; } = new(); public static Manager? Create(ManagerBindingModel model) { if (model == null) { return null; } return new() { Id = model.Id, FIO = model.FIO, Login = model.Login, Password = model.Password, PhoneNumber = model.PhoneNumber }; } public void Update(ManagerBindingModel model) { if (model == null) { return; } FIO = model.FIO; Login = model.Login; Password = model.Password; PhoneNumber = model.PhoneNumber; } public ManagerViewModel GetViewModel => new() { Id = Id, FIO = FIO, Login = Login, Password = Password, PhoneNumber = PhoneNumber }; } }