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

55 lines
1.6 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;
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 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,
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,
Count = Count,
Sum = Sum,
DateCreate = DateCreate,
DateImplement = DateImplement,
Id = Id,
Status = Status,
};
}
}