PIbd-21_Raspaev_N.I._FoodOr.../FoodOrders/FoodOrdersListImplement/Models/Order.cs

56 lines
1.6 KiB
C#
Raw Normal View History

2023-02-07 13:00:02 +04:00
using FoodOrdersContracts.BindingModels;
using FoodOrdersContracts.ViewModels;
using FoodOrdersDataModels.Enums;
using FoodOrdersDataModels.Models;
using System.Reflection;
namespace FoodOrdersListImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
2023-02-12 10:11:34 +04:00
public int DishId { get; private set; }
2023-02-07 13:00:02 +04:00
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; }
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,
2023-02-12 10:11:34 +04:00
DishId = model.DishId,
2023-02-07 13:00:02 +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;
}
Status = model.Status;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
2023-02-12 10:11:34 +04:00
DishId = DishId,
2023-02-07 13:00:02 +04:00
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}