using ComputerStoreContracts.BindingModels; using ComputerStoreContracts.ViewModels; using ComputerStoreDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ComputerStoreDatabaseImplement.Models { public class Request : IRequestModel { public int ID { get; private set; } [Required] public int OrderID { get; private set; } [Required] public double Price { get; private set; } [ForeignKey("RequestID")] public virtual List RequestComponents { get; private set; } = new(); public static Request? Create(RequestBindingModel model) { if (model == null) { return null; } return new Request() { ID = model.ID, OrderID = model.OrderID, Price = model.Price }; } public void Update(RequestBindingModel? model) { if (model == null) { return; } OrderID = model.OrderID; Price = model.Price; } public RequestViewModel GetViewModel => new() { ID = ID, OrderID = OrderID, Price = Price }; } }