2024-02-26 10:12:21 +04:00
|
|
|
|
using FurnitureAssemblyContracts.BindingModels;
|
|
|
|
|
using FurnitureAssemblyContracts.ViewModels;
|
|
|
|
|
using FurnitureAssemblyDataModels.Enums;
|
|
|
|
|
using FurnitureAssemblyDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2024-05-10 22:00:13 +04:00
|
|
|
|
using System.Reflection;
|
2024-02-26 10:12:21 +04:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace FurnitureAssemblyListImplement.Models
|
|
|
|
|
{
|
|
|
|
|
// Класс, реализующий интерфейс модели заказа
|
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
|
|
|
|
// Методы set сделали приватными, чтобы исключить неразрешённые манипуляции
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
2024-05-10 22:00:13 +04:00
|
|
|
|
public int ClientId { get; private set; }
|
|
|
|
|
|
2024-02-26 10:12:21 +04:00
|
|
|
|
public int FurnitureId { get; private set; }
|
|
|
|
|
|
2024-05-11 02:30:02 +04:00
|
|
|
|
public int? ImplementerId { get; private set; }
|
|
|
|
|
|
2024-02-26 10:12:21 +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; } = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
public DateTime? DateImplement { get; private set; }
|
|
|
|
|
|
|
|
|
|
public static Order? Create(OrderBindingModel? model)
|
|
|
|
|
{
|
2024-05-11 23:36:23 +04:00
|
|
|
|
if (model == null)
|
2024-02-26 10:12:21 +04:00
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Order()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
FurnitureId = model.FurnitureId,
|
2024-05-10 22:00:13 +04:00
|
|
|
|
ClientId = model.ClientId,
|
2024-05-11 23:36:23 +04:00
|
|
|
|
ImplementerId = model.ImplementerId,
|
|
|
|
|
Count = model.Count,
|
2024-02-26 10:12:21 +04:00
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
Status = model.Status,
|
|
|
|
|
DateCreate = model.DateCreate,
|
|
|
|
|
DateImplement = model.DateImplement,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Метод изменения существующего объекта
|
|
|
|
|
public void Update(OrderBindingModel? model)
|
|
|
|
|
{
|
2024-05-11 23:36:23 +04:00
|
|
|
|
if (model == null)
|
2024-02-26 10:12:21 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-12 00:27:31 +04:00
|
|
|
|
|
2024-02-26 10:12:21 +04:00
|
|
|
|
Status = model.Status;
|
|
|
|
|
DateImplement = model.DateImplement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
FurnitureId = FurnitureId,
|
2024-05-10 22:00:13 +04:00
|
|
|
|
ClientId = ClientId,
|
2024-05-11 23:36:23 +04:00
|
|
|
|
ImplementerId = ImplementerId,
|
|
|
|
|
Count = Count,
|
2024-02-26 10:12:21 +04:00
|
|
|
|
Sum = Sum,
|
|
|
|
|
Status = Status,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|