PIbd-23-Volkov-N.A.-Compute.../ComputersShop/ComputersShopListImplement/Models/Order.cs

74 lines
2.0 KiB
C#
Raw Normal View History

2024-02-05 20:36:39 +04:00
using ComputersShopContracts.BindingModels;
using ComputersShopContracts.ViewModels;
using ComputersShopDataModels.Enums;
using ComputersShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ComputersShopListImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; private set; }
public int ComputerId { get; private set; }
2024-04-01 20:00:17 +04:00
public int ClientId { get; private set; }
2024-02-05 20:36:39 +04:00
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
ComputerId = model.ComputerId,
2024-04-01 20:00:17 +04:00
ClientId = model.ClientId,
2024-02-05 20:36:39 +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,
ComputerId = ComputerId,
2024-04-01 20:00:17 +04:00
ClientId = ClientId,
2024-02-05 20:36:39 +04:00
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
}
}