PIbd-23-Nasyrov-A.G.-Flower.../FlowerShopListImplement/Order.cs

78 lines
2.2 KiB
C#
Raw Normal View History

2024-02-08 17:08:13 +04:00
using FlowerShopContracts.BindingModels;
using FlowerShopContracts.ViewModels;
using FlowerShopDataModels.Enums;
using FlowerShopDataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2024-04-22 20:09:58 +04:00
using System.Reflection;
2024-02-08 17:08:13 +04:00
namespace FlowerShopListImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int FlowerId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
2024-04-06 18:45:56 +04:00
public int ClientId { get; private set; }
2024-04-22 20:09:58 +04:00
public int? ImplementerId { get; private set; }
2024-04-06 18:45:56 +04:00
2024-04-22 20:09:58 +04:00
public OrderStatus Status { get; private set; }
2024-02-08 17:08:13 +04:00
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,
FlowerId = model.FlowerId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
2024-04-06 18:45:56 +04:00
ClientId = model.ClientId,
2024-04-22 20:09:58 +04:00
ImplementerId = model.ImplementerId
2024-04-06 18:45:56 +04:00
2024-04-22 20:09:58 +04:00
};
2024-02-08 17:08:13 +04:00
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
Id = model.Id;
FlowerId = model.FlowerId;
Count = model.Count;
2024-04-06 18:45:56 +04:00
ClientId = model.ClientId;
2024-04-22 20:09:58 +04:00
ImplementerId = model.ImplementerId;
Sum = model.Sum;
2024-02-08 17:08:13 +04:00
Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
FlowerId = FlowerId,
2024-04-06 18:45:56 +04:00
ClientId = ClientId,
2024-04-22 20:09:58 +04:00
ImplementerId = ImplementerId,
Count = Count,
2024-02-08 17:08:13 +04:00
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement,
};
}
}