2023-01-31 15:23:18 +04:00
|
|
|
|
using SushiBarContracts.BindingModels;
|
|
|
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
|
using SushiBarDataModels.Enums;
|
|
|
|
|
using SushiBarDataModels.Models;
|
2023-03-25 00:57:08 +04:00
|
|
|
|
using System.Reflection;
|
2023-01-31 15:23:18 +04:00
|
|
|
|
|
|
|
|
|
namespace SushiBarListImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
2023-02-07 12:55:45 +04:00
|
|
|
|
public int Id { get; private set; }
|
2023-01-31 15:23:18 +04:00
|
|
|
|
public int SushiId { get; private set; }
|
2023-03-25 00:57:08 +04:00
|
|
|
|
public int ClientId { get; private set; }
|
2023-01-31 15:23:18 +04:00
|
|
|
|
public int Count { get; private set; }
|
|
|
|
|
public double Sum { get; private set; }
|
|
|
|
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
|
|
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
|
|
|
|
public DateTime? DateImplement { get; private set; }
|
|
|
|
|
public static Order? Create(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Order
|
|
|
|
|
{
|
|
|
|
|
SushiId = model.SushiId,
|
2023-03-25 00:57:08 +04:00
|
|
|
|
ClientId = model.ClientId,
|
2023-01-31 15:23:18 +04:00
|
|
|
|
Count = model.Count,
|
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
Status = model.Status,
|
|
|
|
|
DateCreate = model.DateCreate,
|
|
|
|
|
DateImplement = model.DateImplement,
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public void Update(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Status = model.Status;
|
2023-02-12 13:11:05 +04:00
|
|
|
|
DateImplement = model.DateImplement;
|
2023-01-31 15:23:18 +04:00
|
|
|
|
}
|
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
SushiId = SushiId,
|
2023-03-25 00:57:08 +04:00
|
|
|
|
ClientId = ClientId,
|
2023-01-31 15:23:18 +04:00
|
|
|
|
Count = Count,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement,
|
|
|
|
|
Id = Id,
|
|
|
|
|
Status = Status,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|