2024-03-25 20:21:59 +04:00
|
|
|
|
using AbstractLawFirmContracts.BindingModels;
|
|
|
|
|
using AbstractLawFirmContracts.ViewModels;
|
2024-04-20 14:07:58 +04:00
|
|
|
|
using AbstractLawFirmDataBaseImplement.Models;
|
2024-03-25 20:21:59 +04:00
|
|
|
|
using AbstractLawFirmDataModels.Enums;
|
|
|
|
|
using AbstractLawFirmDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-04-09 23:28:01 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2024-03-25 20:21:59 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2024-04-09 23:28:01 +04:00
|
|
|
|
namespace AbstractLawFirmDatabaseImplement.Models
|
2024-03-25 20:21:59 +04:00
|
|
|
|
{
|
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
2024-04-09 23:28:01 +04:00
|
|
|
|
[Required]
|
2024-03-25 20:21:59 +04:00
|
|
|
|
public int DocumentId { get; private set; }
|
2024-04-09 23:28:01 +04:00
|
|
|
|
[Required]
|
2024-04-20 14:07:58 +04:00
|
|
|
|
public int ClientId { get; private set; }
|
|
|
|
|
[Required]
|
2024-03-25 20:21:59 +04:00
|
|
|
|
public int Count { get; private set; }
|
2024-04-09 23:28:01 +04:00
|
|
|
|
[Required]
|
2024-03-25 20:21:59 +04:00
|
|
|
|
public double Sum { get; private set; }
|
2024-04-09 23:28:01 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
|
|
|
|
|
2024-03-25 20:21:59 +04:00
|
|
|
|
public DateTime? DateImplement { get; private set; }
|
2024-04-09 23:28:01 +04:00
|
|
|
|
public virtual Document Document { get; set; }
|
2024-04-20 14:07:58 +04:00
|
|
|
|
public virtual Client Client { get; set; }
|
2024-04-09 23:28:01 +04:00
|
|
|
|
|
2024-03-25 20:21:59 +04:00
|
|
|
|
public static Order? Create(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2024-04-09 23:28:01 +04:00
|
|
|
|
return new Order
|
2024-03-25 20:21:59 +04:00
|
|
|
|
{
|
|
|
|
|
DocumentId = model.DocumentId,
|
2024-04-20 14:07:58 +04:00
|
|
|
|
ClientId = model.ClientId,
|
2024-03-25 20:21:59 +04:00
|
|
|
|
Count = model.Count,
|
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
Status = model.Status,
|
|
|
|
|
DateCreate = model.DateCreate,
|
|
|
|
|
DateImplement = model.DateImplement,
|
2024-04-09 23:28:01 +04:00
|
|
|
|
Id = model.Id,
|
2024-03-25 20:21:59 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-09 23:28:01 +04:00
|
|
|
|
|
2024-03-25 20:21:59 +04:00
|
|
|
|
public void Update(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Status = model.Status;
|
|
|
|
|
DateImplement = model.DateImplement;
|
|
|
|
|
}
|
2024-04-09 23:28:01 +04:00
|
|
|
|
|
|
|
|
|
public OrderViewModel GetViewModel => new OrderViewModel
|
2024-03-25 20:21:59 +04:00
|
|
|
|
{
|
|
|
|
|
DocumentId = DocumentId,
|
2024-04-20 14:07:58 +04:00
|
|
|
|
ClientId = ClientId,
|
2024-03-25 20:21:59 +04:00
|
|
|
|
Count = Count,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement,
|
2024-04-09 23:28:01 +04:00
|
|
|
|
Id = Id,
|
|
|
|
|
Status = Status,
|
2024-04-20 14:07:58 +04:00
|
|
|
|
DocumentName = Document?.DocumentName ?? string.Empty,
|
|
|
|
|
ClientFIO = Client.ClientFIO
|
2024-03-25 20:21:59 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-04-09 23:28:01 +04:00
|
|
|
|
}
|