2023-04-07 18:58:07 +04:00
|
|
|
|
using CanteenDataModels.Models;
|
|
|
|
|
using System;
|
2023-04-07 10:55:40 +04:00
|
|
|
|
using System.Collections.Generic;
|
2023-04-07 18:58:07 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-04-07 10:55:40 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-04-09 00:34:25 +04:00
|
|
|
|
using CanteenContracts.BindingModels;
|
|
|
|
|
using CanteenContracts.View;
|
|
|
|
|
using NHibernate.Mapping;
|
2023-04-07 10:55:40 +04:00
|
|
|
|
|
|
|
|
|
namespace CanteenDatabaseImplement.Models
|
|
|
|
|
{
|
2023-04-07 18:58:07 +04:00
|
|
|
|
public class Tableware : ITablewareModel
|
2023-04-07 10:55:40 +04:00
|
|
|
|
{
|
2023-04-07 18:58:07 +04:00
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int VisitorId { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public string TablewareName { get; private set; } = string.Empty;
|
|
|
|
|
[ForeignKey("TablewareId")]
|
2023-05-19 03:39:58 +04:00
|
|
|
|
public virtual List<OrderTableware> Orders { get; set; } = new();
|
2023-04-09 00:34:25 +04:00
|
|
|
|
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,
|
2023-05-18 01:40:11 +04:00
|
|
|
|
TablewareName = model.TablewareName
|
2023-04-09 00:34:25 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
};
|
2023-04-07 10:55:40 +04:00
|
|
|
|
}
|
|
|
|
|
}
|