PIbd-21_Balberova_D.N._Sush.../SushiBar/SushiBarListImplement/Models/Order.cs

59 lines
1.8 KiB
C#
Raw Normal View History

2023-01-31 15:23:18 +04:00
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
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; }
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,
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,
ClientId = ClientId,
2023-01-31 15:23:18 +04:00
Count = Count,
Sum = Sum,
DateCreate = DateCreate,
DateImplement = DateImplement,
Id = Id,
Status = Status,
};
}
}