2024-03-14 18:53:30 +04:00
|
|
|
|
using CarRepairShopContracts.BindingModels;
|
|
|
|
|
using CarRepairShopContracts.ViewModels;
|
|
|
|
|
using CarRepairShopDataModels.Enums;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
|
|
|
|
namespace CarRepairShopDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class Order
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int Count { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public double Sum { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public OrderStatus Status { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateCreate { get; private set; }
|
|
|
|
|
public DateTime? DateImplement { get; private set; }
|
|
|
|
|
[Required]
|
|
|
|
|
public int RepairId { get; private set; }
|
2024-03-25 22:06:48 +04:00
|
|
|
|
public virtual Repair? Repair { get; set; }
|
2024-03-14 18:53:30 +04:00
|
|
|
|
|
2024-03-24 21:23:30 +04:00
|
|
|
|
public static Order? Create(OrderBindingModel model)
|
2024-03-14 18:53:30 +04:00
|
|
|
|
{
|
|
|
|
|
return new Order()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Count = model.Count,
|
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
Status = model.Status,
|
|
|
|
|
DateCreate = model.DateCreate,
|
|
|
|
|
DateImplement = model.DateImplement,
|
|
|
|
|
RepairId = model.RepairId,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(OrderBindingModel? model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Status = model.Status;
|
|
|
|
|
DateImplement = model.DateImplement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
RepairId = RepairId,
|
2024-03-25 22:06:48 +04:00
|
|
|
|
RepairName = Repair?.RepairName ?? string.Empty,
|
2024-03-14 18:53:30 +04:00
|
|
|
|
Count = Count,
|
|
|
|
|
Sum = Sum,
|
|
|
|
|
Status = Status,
|
|
|
|
|
DateCreate = DateCreate,
|
|
|
|
|
DateImplement = DateImplement,
|
2024-03-24 20:29:38 +04:00
|
|
|
|
Id = Id
|
2024-03-14 18:53:30 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|