59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
|
using DinerContracts.BindingModels;
|
|||
|
using DinerContracts.ViewModels;
|
|||
|
using DinerDataModels.Enums;
|
|||
|
using DinerDataModels.Models;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace DinerListImplement.Models
|
|||
|
{
|
|||
|
internal class Order : IOrderModel
|
|||
|
{
|
|||
|
public int ProductID { get; private set; }
|
|||
|
|
|||
|
public int Count { get; set; }
|
|||
|
|
|||
|
public double Sum { get; private set; }
|
|||
|
|
|||
|
public OrderStatus Status { get; set; }
|
|||
|
|
|||
|
public DateTime DateCreate { get; private set; }
|
|||
|
|
|||
|
public DateTime? DateImplement { get; set; }
|
|||
|
|
|||
|
public int ID { get; private set; }
|
|||
|
|
|||
|
public static Order? Create(OrderBindingModel? model) {
|
|||
|
if (model == null) return null;
|
|||
|
return new Order()
|
|||
|
{
|
|||
|
ID = model.ID,
|
|||
|
ProductID = model.ProductID,
|
|||
|
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,
|
|||
|
ProductID = ProductID,
|
|||
|
Count = Count,
|
|||
|
Sum = Sum,
|
|||
|
Status = Status,
|
|||
|
DateCreate = DateCreate,
|
|||
|
DateImplement = DateImplement,
|
|||
|
};
|
|||
|
}
|
|||
|
}
|