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 DateOnly OrderDeliveryTime { get; set; } = DateOnly.FromDateTime(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, }; } }