From 50e7193a47104557c6d8d8c2154d185974d88ad5 Mon Sep 17 00:00:00 2001
From: Safgerd <safgerdfeed@gmail.com>
Date: Sat, 20 May 2023 05:52:38 +0400
Subject: [PATCH] Fix

---
 ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs  | 1 -
 ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs      | 1 -
 .../BindingModels/ConsignmentBindingModel.cs                  | 2 +-
 ComputerStoreContracts/BindingModels/RequestBindingModel.cs   | 2 +-
 ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs     | 2 +-
 ComputerStoreContracts/ViewModels/RequestViewModel.cs         | 2 +-
 ComputerStoreDataModels/Models/IConsignmentModel.cs           | 2 +-
 ComputerStoreDataModels/Models/IRequestModel.cs               | 2 +-
 ComputerStoreDatabaseImplement/Models/Consignment.cs          | 4 ++--
 ComputerStoreDatabaseImplement/Models/Request.cs              | 4 ++--
 10 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs b/ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
index 1faeded..3cdc271 100644
--- a/ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
+++ b/ComputerStoreBusinessLogic/BusinessLogic/ConsignmentLogic.cs
@@ -97,7 +97,6 @@ namespace ComputerStoreBusinessLogic.BusinessLogic
             if (model == null) { return; }
             if (!withParams) { return; }
             if (model.Price <= 0) { throw new ArgumentNullException("Invalid consignment's price", nameof(model)); }
-            if (string.IsNullOrEmpty(model.OrderID.ToString())) { throw new ArgumentNullException("Invalid Consignment's order ID", nameof(model)); }
 
             _logger.LogInformation("Consignment. Consignment ID:{ ID}. Order ID:{ OrderID}.", model.ID, model.OrderID);
         }
diff --git a/ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs b/ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
index c0ce395..77dad3f 100644
--- a/ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
+++ b/ComputerStoreBusinessLogic/BusinessLogic/RequestLogic.cs
@@ -97,7 +97,6 @@ namespace ComputerStoreBusinessLogic.BusinessLogic
             if (model == null) { return; }
             if (!withParams) { return; }
             if (model.Price <= 0) { throw new ArgumentNullException("Invalid request's price", nameof(model)); }
-            if (string.IsNullOrEmpty(model.OrderID.ToString())) { throw new ArgumentNullException("Invalid Request's order ID", nameof(model)); }
 
             _logger.LogInformation("Request. Request ID:{ ID}. Order ID: { OrderID}. PC ID: { PCID}", model.ID, model.OrderID, model.PCID);
         }
diff --git a/ComputerStoreContracts/BindingModels/ConsignmentBindingModel.cs b/ComputerStoreContracts/BindingModels/ConsignmentBindingModel.cs
index 08d0a50..68ac69c 100644
--- a/ComputerStoreContracts/BindingModels/ConsignmentBindingModel.cs
+++ b/ComputerStoreContracts/BindingModels/ConsignmentBindingModel.cs
@@ -10,7 +10,7 @@ namespace ComputerStoreContracts.BindingModels
     public class ConsignmentBindingModel : IConsignmentModel
     {
         public int ID { get; set; }
-        public int OrderID { get; set; }
+        public int? OrderID { get; set; }
         public double Price { get; set; }
         public Dictionary<int, (IProductModel, int)> ConsignmentProducts { get; set; } = new();
     }
diff --git a/ComputerStoreContracts/BindingModels/RequestBindingModel.cs b/ComputerStoreContracts/BindingModels/RequestBindingModel.cs
index e1d8d53..2b34ef5 100644
--- a/ComputerStoreContracts/BindingModels/RequestBindingModel.cs
+++ b/ComputerStoreContracts/BindingModels/RequestBindingModel.cs
@@ -10,7 +10,7 @@ namespace ComputerStoreContracts.BindingModels
     public class RequestBindingModel : IRequestModel
     {
         public int ID { get; set; }
-        public int OrderID { get; set; }
+        public int? OrderID { get; set; }
         public double Price { get; set; }
         public int? PCID { get; set; }
 
diff --git a/ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs b/ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs
index 9e64aaf..97730c2 100644
--- a/ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs
+++ b/ComputerStoreContracts/ViewModels/ConsignmentViewModel.cs
@@ -13,7 +13,7 @@ namespace ComputerStoreContracts.ViewModels
         [DisplayName("Consignment ID")]
         public int ID { get; set; }
         [DisplayName("Order ID")]
-        public int OrderID { get; set; }
+        public int? OrderID { get; set; }
         [DisplayName("Price")]
         public double Price { get; set; }
 
diff --git a/ComputerStoreContracts/ViewModels/RequestViewModel.cs b/ComputerStoreContracts/ViewModels/RequestViewModel.cs
index 1e52e88..f9b13be 100644
--- a/ComputerStoreContracts/ViewModels/RequestViewModel.cs
+++ b/ComputerStoreContracts/ViewModels/RequestViewModel.cs
@@ -13,7 +13,7 @@ namespace ComputerStoreContracts.ViewModels
         [DisplayName("Request ID")]
         public int ID { get; set; }
         [DisplayName("Order ID")]
-        public int OrderID { get; set; }
+        public int? OrderID { get; set; }
         [DisplayName("Price")]
         public double Price { get; set; }
 
diff --git a/ComputerStoreDataModels/Models/IConsignmentModel.cs b/ComputerStoreDataModels/Models/IConsignmentModel.cs
index a114658..2ac7a40 100644
--- a/ComputerStoreDataModels/Models/IConsignmentModel.cs
+++ b/ComputerStoreDataModels/Models/IConsignmentModel.cs
@@ -8,7 +8,7 @@ namespace ComputerStoreDataModels.Models
 {
     public interface IConsignmentModel : IID
     {
-        int OrderID { get; }
+        int? OrderID { get; }
         double Price { get; }
         Dictionary<int, (IProductModel, int)> ConsignmentProducts { get; }
     }
diff --git a/ComputerStoreDataModels/Models/IRequestModel.cs b/ComputerStoreDataModels/Models/IRequestModel.cs
index 6f12f57..2164862 100644
--- a/ComputerStoreDataModels/Models/IRequestModel.cs
+++ b/ComputerStoreDataModels/Models/IRequestModel.cs
@@ -8,7 +8,7 @@ namespace ComputerStoreDataModels.Models
 {
     public interface IRequestModel : IID
     {
-        int OrderID { get; }
+        int? OrderID { get; }
         int? PCID { get; }
         double Price { get; }
 
diff --git a/ComputerStoreDatabaseImplement/Models/Consignment.cs b/ComputerStoreDatabaseImplement/Models/Consignment.cs
index 7ea066f..3d2cfac 100644
--- a/ComputerStoreDatabaseImplement/Models/Consignment.cs
+++ b/ComputerStoreDatabaseImplement/Models/Consignment.cs
@@ -16,8 +16,7 @@ namespace ComputerStoreDatabaseImplement.Models
     {
         public int ID { get; private set; }
 
-        [Required]
-        public int OrderID { get; private set; }
+        public int? OrderID { get; private set; }
         public virtual Order Order { get; set; }
 
         [Required]
@@ -68,6 +67,7 @@ namespace ComputerStoreDatabaseImplement.Models
                 return;
             }
             Price = model.Price;
+            OrderID = model.OrderID;
         }
         public ConsignmentViewModel GetViewModel => new()
         {
diff --git a/ComputerStoreDatabaseImplement/Models/Request.cs b/ComputerStoreDatabaseImplement/Models/Request.cs
index 18bb3ad..7f2b350 100644
--- a/ComputerStoreDatabaseImplement/Models/Request.cs
+++ b/ComputerStoreDatabaseImplement/Models/Request.cs
@@ -19,8 +19,7 @@ namespace ComputerStoreDatabaseImplement.Models
     {
         public int ID { get; private set; }
 
-        [Required]
-        public int OrderID { get; private set; }
+        public int? OrderID { get; private set; }
         public virtual Order Order { get; set; }
 
         public int? PCID { get; private set; }
@@ -61,6 +60,7 @@ namespace ComputerStoreDatabaseImplement.Models
             }
             Price = model.Price;
             PCID = model.PCID;
+            OrderID = model.OrderID;
             RequestComponents = model.RequestComponents;
         }