using CanteenDataModels.Models; 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 CanteenContracts.BindingModels; using CanteenContracts.View; using NHibernate.Mapping; namespace CanteenDatabaseImplement.Models { public class Tableware : ITablewareModel { public int Id { get; private set; } [Required] public int VisitorId { get; private set; } [Required] public string TablewareName { get; private set; } = string.Empty; [ForeignKey("TablewareId")] public virtual List Orders { get; set; } = new(); public virtual Visitor Visitor { get; set; } public static Tableware? Create(TablewareBindingModel model) { if (model == null) { return null; } return new() { Id = model.Id, VisitorId = model.VisitorId, TablewareName = model.TablewareName }; } public void Update(TablewareBindingModel model) { if (model == null) { return; } Id = model.Id; VisitorId = model.VisitorId; TablewareName = model.TablewareName; } public TablewareViewModel GetViewModel => new() { Id = Id, VisitorId = VisitorId, TablewareName = TablewareName }; } }