2024-05-07 17:56:47 +04:00
|
|
|
|
using SecuritySystemContracts.BindingModels;
|
|
|
|
|
using SecuritySystemContracts.ViewModels;
|
|
|
|
|
using SecuritySystemDataModels.Enums;
|
|
|
|
|
using SecuritySystemDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SecuritySystemDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public int SecureId { get; private set; }
|
|
|
|
|
|
2024-05-08 08:03:51 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int ClientId { get; private set; }
|
|
|
|
|
|
2024-05-08 08:37:10 +04:00
|
|
|
|
public int? ImplementerId { get; private set; }
|
|
|
|
|
|
2024-05-07 17:56:47 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int Count { get; private set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public double Sum { get; private set; }
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
|
|
|
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
public DateTime? DateImplement { get; private set; }
|
|
|
|
|
|
|
|
|
|
//для передачи названия изделия
|
|
|
|
|
public virtual Secure Secure { get; set; }
|
|
|
|
|
|
2024-05-08 08:03:51 +04:00
|
|
|
|
//для передачи имени клиента
|
|
|
|
|
public virtual Client Client { get; set; }
|
|
|
|
|
|
2024-05-08 08:37:10 +04:00
|
|
|
|
//для передачи имени исполнителя
|
|
|
|
|
public virtual Implementer? Implementer { get; set; }
|
|
|
|
|
|
2024-05-07 17:56:47 +04:00
|
|
|
|
public static Order? Create(OrderBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Order()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
SecureId = model.SecureId,
|
2024-05-08 08:03:51 +04:00
|
|
|
|
ClientId = model.ClientId,
|
2024-05-08 08:37:10 +04:00
|
|
|
|
ImplementerId = model.ImplementerId,
|
2024-05-07 17:56:47 +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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-08 08:37:10 +04:00
|
|
|
|
ImplementerId = model.ImplementerId;
|
2024-05-07 17:56:47 +04:00
|
|
|
|
Status = model.Status;
|
|
|
|
|
DateImplement = model.DateImplement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
SecureId = SecureId,
|
2024-05-08 08:03:51 +04:00
|
|
|
|
ClientId = ClientId,
|
2024-05-08 08:37:10 +04:00
|
|
|
|
ImplementerId = ImplementerId,
|
2024-05-07 17:56:47 +04:00
|
|
|
|
Count = Count,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
Status = Status,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement,
|
2024-05-08 08:03:51 +04:00
|
|
|
|
SecureName = Secure.SecureName,
|
2024-05-08 08:37:10 +04:00
|
|
|
|
ClientFIO = Client.ClientFIO,
|
|
|
|
|
ImplementerFIO = Implementer?.ImplementerFIO
|
2024-05-07 17:56:47 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|