2023-04-19 17:50:19 +03:00
|
|
|
|
using AutomobilePlantContracts.BindingModels;
|
|
|
|
|
using AutomobilePlantContracts.ViewModel;
|
|
|
|
|
using AutomobilePlantDataModels.Enums;
|
|
|
|
|
using AutomobilePlantDataModels.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-04-19 19:38:34 +03:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2023-04-19 17:50:19 +03:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AutomobilePlantDataBaseImplements.Models
|
|
|
|
|
{
|
|
|
|
|
public class Order : IOrderModel
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int CarId { get; private set; }
|
2023-04-19 18:58:31 +03:00
|
|
|
|
[Required]
|
|
|
|
|
public int ClientId { get; private set; }
|
|
|
|
|
public string ClientName { get; private set; } = string.Empty;
|
2023-04-19 19:38:34 +03:00
|
|
|
|
public int? ImplementerId { get; private set; }
|
|
|
|
|
public string? ImplementerName { get; private set; } = string.Empty;
|
2023-04-19 18:58:31 +03:00
|
|
|
|
public string CarName { get; private set; } = string.Empty;
|
|
|
|
|
public Client client { get; private set; }
|
2023-04-19 17:50:19 +03:00
|
|
|
|
public Car car { get; private set; }
|
2023-04-19 19:38:34 +03:00
|
|
|
|
public Implementer? implementer { get; private set; }
|
2023-04-19 17:50:19 +03: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.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
|
|
|
|
public DateTime? DateImplement { get; private set; }
|
|
|
|
|
|
|
|
|
|
public static Order? Create(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new Order()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
CarId = model.CarId,
|
2023-04-19 18:58:31 +03:00
|
|
|
|
ClientId = model.ClientId,
|
2023-04-19 17:50:19 +03:00
|
|
|
|
CarName = model.CarName,
|
2023-04-19 18:58:31 +03:00
|
|
|
|
ClientName = model.ClientName,
|
2023-04-19 17:50:19 +03: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;
|
|
|
|
|
}
|
2023-04-19 19:38:34 +03:00
|
|
|
|
ImplementerId = model.ImplementerId;
|
|
|
|
|
ImplementerName = model.ImplementerName;
|
2023-04-19 17:50:19 +03:00
|
|
|
|
Status = model.Status;
|
|
|
|
|
DateImplement = model.DateImplement;
|
2023-04-19 19:38:34 +03:00
|
|
|
|
|
2023-04-19 17:50:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
CarId = CarId,
|
2023-04-19 18:58:31 +03:00
|
|
|
|
ClientId = ClientId,
|
2023-04-19 19:38:34 +03:00
|
|
|
|
ImplementerId = ImplementerId,
|
|
|
|
|
ImplementerName=ImplementerName,
|
2023-04-19 17:50:19 +03:00
|
|
|
|
CarName = CarName,
|
2023-04-19 18:58:31 +03:00
|
|
|
|
ClientName = ClientName,
|
2023-04-19 17:50:19 +03:00
|
|
|
|
Count = Count,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
Status = Status,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|