PIbd-21_BatylkinaAO_MusoevD.../Canteen/CanteenDatabaseImplement/Models/Tableware.cs

60 lines
1.6 KiB
C#
Raw Normal View History

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-20 12:11:48 +04:00
public virtual List<OrderTableware> Orders { get; set; }
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
}
}