53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using Contracts.BindingModels;
|
|
using Contracts.ViewModels;
|
|
using DataModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace DataBaseImplements.Models
|
|
{
|
|
public class Order : IOrderModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string FIO { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string[] OrderPath { get; set; } = new string[0];
|
|
|
|
[Required]
|
|
public string OrderDestination { get; set; } = string.Empty;
|
|
|
|
public DateTime OrderDeliveryTime { get; set; } = DateTime.Today;
|
|
|
|
public static Order? Create(OrderBindingModel model)
|
|
{
|
|
return new Order
|
|
{
|
|
Id = model.Id,
|
|
FIO = model.FIO,
|
|
OrderPath = model.OrderPath,
|
|
OrderDestination = model.OrderDestination,
|
|
OrderDeliveryTime = model.OrderDeliveryTime,
|
|
};
|
|
}
|
|
|
|
public void Update(OrderBindingModel model)
|
|
{
|
|
FIO = model.FIO;
|
|
OrderPath = model.OrderPath;
|
|
OrderDestination = model.OrderDestination;
|
|
OrderDeliveryTime = model.OrderDeliveryTime;
|
|
}
|
|
|
|
public OrderViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
FIO = FIO,
|
|
OrderPath = OrderPath,
|
|
OrderDestination = OrderDestination,
|
|
OrderDeliveryTime = OrderDeliveryTime,
|
|
};
|
|
}
|
|
}
|