using InternetShopContracts.DataBindingModels; using InternetShopContracts.DataViewModels; using InternetShopDataModels.Models; using System.ComponentModel.DataAnnotations; namespace InternetShopDatabase.Models { public class Order : IOrderModel { [Required] public string CustomerFIO { get; set; } = string.Empty; [Required] public string CustomerEmail { get; set; } = string.Empty; [Required] public string ImagePath { get; set; } = string.Empty; public List ProductNames { get; set; } = new List(); public int Id { get; set; } public OrderViewModel GetViewModel => new() { Id = Id, CustomerFIO = CustomerFIO, CustomerEmail = CustomerEmail, ImagePath = ImagePath, ProductNames = ProductNames, }; public static Order Create(OrderBindingModel model) { return new Order() { Id = model.Id, CustomerFIO = model.CustomerFIO, CustomerEmail = model.CustomerEmail, ImagePath = model.ImagePath, ProductNames = model.ProductNames, }; } public void Update(OrderBindingModel model) { CustomerFIO = model.CustomerFIO; CustomerEmail = model.CustomerEmail; ImagePath = model.ImagePath; ProductNames = model.ProductNames; } } }