using CanteenContracts.BindingModels; 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; namespace CanteenDatabaseImplement.Models { public class Visitor : IVisitorModel { [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("VisitorId")] public virtual List Orders { get; set; } = new(); [ForeignKey("VisitorId")] public virtual List Lunches { get; set; } = new(); [ForeignKey("VisitorId")] public virtual List Tablewares { get; set; } = new(); public static Visitor? Create(VisitorBindingModel 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(VisitorBindingModel model) { if (model == null) { return; } FIO = model.FIO; Login = model.Login; Password = model.Password; PhoneNumber = model.PhoneNumber; } public VisitorViewModel GetViewModel => new() { Id = Id, FIO = FIO, Login = Login, Password = Password, PhoneNumber = PhoneNumber }; } }