2024-02-14 21:52:00 +04:00
|
|
|
|
using SushiBarContracts.BindingModels;
|
|
|
|
|
using SushiBarContracts.ViewModels;
|
|
|
|
|
using SushiBarDataModels.Enums;
|
|
|
|
|
using SushiBarDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace SushiBarListImplement.Models
|
|
|
|
|
{
|
2024-05-22 21:31:27 +04:00
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
public int SushiId { get; private set; }
|
2024-05-03 22:00:08 +04:00
|
|
|
|
public int ClientId { get; private set; }
|
|
|
|
|
public int Count { get; private set; }
|
2024-05-22 21:31:27 +04:00
|
|
|
|
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 int? ImplementerId { get; private set; }
|
2024-02-14 21:52:00 +04:00
|
|
|
|
|
2024-05-22 21:31:27 +04:00
|
|
|
|
public static Order? Create(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Order()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
SushiId = model.SushiId,
|
2024-05-03 22:00:08 +04:00
|
|
|
|
ClientId = model.ClientId,
|
2024-05-22 21:31:27 +04:00
|
|
|
|
ImplementerId = model.ImplementerId,
|
2024-05-03 22:00:08 +04:00
|
|
|
|
Count = model.Count,
|
2024-05-22 21:31:27 +04:00
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
Status = model.Status,
|
|
|
|
|
DateCreate = model.DateCreate,
|
|
|
|
|
DateImplement = model.DateImplement,
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-02-14 21:52:00 +04:00
|
|
|
|
|
2024-05-22 21:31:27 +04:00
|
|
|
|
public void Update(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Status = model.Status;
|
|
|
|
|
if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement;
|
|
|
|
|
}
|
2024-02-14 21:52:00 +04:00
|
|
|
|
|
2024-05-22 21:31:27 +04:00
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
SushiId = SushiId,
|
2024-05-03 22:00:08 +04:00
|
|
|
|
ClientId = ClientId,
|
2024-05-22 21:31:27 +04:00
|
|
|
|
ImplementerId = ImplementerId,
|
2024-05-03 22:00:08 +04:00
|
|
|
|
Count = Count,
|
2024-05-22 21:31:27 +04:00
|
|
|
|
Sum = Sum,
|
|
|
|
|
Status = Status,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement,
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-02-14 21:52:00 +04:00
|
|
|
|
}
|