PIbd-22_Chubykina_P.P._Conf.../Confectionery/ConfectioneryListImplement/Order.cs

69 lines
1.7 KiB
C#
Raw Normal View History

using ConfectioneryContracts.BindingModels;
using ConfectioneryContracts.ViewModels;
using ConfectioneryDataModels.Enums;
using ConfectioneryDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConfectioneryListImplement
{
internal class Order : IOrderModel
{
2024-02-28 10:03:27 +04:00
public int Id { get; private set; }
2024-02-28 10:03:27 +04:00
public int PastryId { get; private set; }
2024-02-28 10:03:27 +04:00
public int Count { get; private set; }
2024-02-28 10:03:27 +04:00
public double Sum { get; private set; }
2024-02-28 10:03:27 +04:00
public OrderStatus Status { get; private set; }
2024-02-28 10:03:27 +04:00
public DateTime DateCreate { get; private set; }
2024-02-28 10:03:27 +04:00
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
2024-02-28 10:03:27 +04:00
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
PastryId = model.PastryId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
}
public void Update(OrderBindingModel? model)
{
2024-02-28 10:03:27 +04:00
if (model == null)
{
return;
}
Status = model.Status;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
2024-02-28 10:03:27 +04:00
Id = Id,
PastryId = PastryId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}