using AccountingWarehouseProductsContracts.BindingModels; using AccountingWarehouseProductsContracts.ViewModels; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AccountingWarehouseProductsDatabaseImplement.Models { public class Shipment { public int Id { get; set; } [Required] public string ShipmentDate { get; set; } = string.Empty; [Required] public int Count { get; set; } [Required] public string Recipient { get; set; } = string.Empty; [Required] public int OrderId { get; set; } public static Shipment? Create(ShipmentBindingModel model) { if (model == null) return null; return new Shipment() { Id = model.Id, ShipmentDate = model.ShipmentDate, Count = model.Count, Recipient = model.Recipient, OrderId = model.OrderId }; } public void Update(ShipmentBindingModel model) { if (model == null) return; ShipmentDate = model.ShipmentDate; Count = model.Count; Recipient = model.Recipient; OrderId = model.OrderId; } public ShipmentViewModel GetViewModel => new() { Id = Id, ShipmentDate = ShipmentDate, Count = Count, Recipient = Recipient, OrderId = OrderId }; } }