SushiBarBase/SushiBar/SushiBarListImplement/Models/Order.cs

62 lines
1.9 KiB
C#
Raw Normal View History

2024-02-09 17:38:25 +04:00
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels;
using SushiBarDataModels.Enums;
using SushiBarDataModels.Models;
namespace SushiBarListImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int SushiId { get; private set; }
2024-05-04 21:53:45 +04:00
public int ClientId { get; private set; }
2024-05-08 08:52:27 +04:00
public int? ImplementerId { get; private set; }
2024-02-09 17:38:25 +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; }
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model) {
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
SushiId = model.SushiId,
2024-05-19 17:58:47 +04:00
ClientId = model.ClientId,
2024-02-09 17:38:25 +04:00
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
SushiId = model.SushiId;
2024-05-19 17:58:47 +04:00
ClientId = model.ClientId;
2024-02-09 17:38:25 +04:00
Count = model.Count;
Sum = model.Sum;
Status = model.Status;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
SushiId = SushiId,
2024-05-19 17:58:47 +04:00
ClientId = ClientId,
2024-02-09 17:38:25 +04:00
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}