diff --git a/CarCenter/CarCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs b/CarCenter/CarCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs index 9fdb50c..f06e905 100644 --- a/CarCenter/CarCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs +++ b/CarCenter/CarCenterBusinessLogic/BusinessLogics/EquipmentLogic.cs @@ -3,6 +3,7 @@ using CarCenterContracts.BusinessLogicsContracts; using CarCenterContracts.SearchModels; using CarCenterContracts.StoragesContracts; using CarCenterContracts.ViewModels; +using CarCenterDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -107,6 +108,39 @@ namespace CarCenterBusinessLogic.BusinessLogics return true; } + public bool AddCarToEquipment(EquipmentSearchModel model, ICarModel car) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("AddCarToEquipment. EquipmentName:{EquipmentName}.Id:{ Id}", model.EquipmentName, model.Id); + var element = _equipmentStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("AddCarToEquipment element not found"); + return false; + } + + _logger.LogInformation("AddCarToEquipment find. Id:{Id}", element.Id); + + element.EquipmentCars[car.Id] = car; + + _equipmentStorage.Update(new() + { + Id = element.Id, + EquipmentName = element.EquipmentName, + EquipmentPrice = element.EquipmentPrice, + AdministratorId = element.AdministratorId, + PreSaleWorkId = element.PreSaleWorkId, + EquipmentCars = element.EquipmentCars, + }); + + return true; + } + private void CheckModel(EquipmentBindingModel model, bool withParams = true) { if (model == null) diff --git a/CarCenter/CarCenterBusinessLogic/BusinessLogics/InspectionLogic.cs b/CarCenter/CarCenterBusinessLogic/BusinessLogics/InspectionLogic.cs index de69b5f..9cf313f 100644 --- a/CarCenter/CarCenterBusinessLogic/BusinessLogics/InspectionLogic.cs +++ b/CarCenter/CarCenterBusinessLogic/BusinessLogics/InspectionLogic.cs @@ -3,6 +3,7 @@ using CarCenterContracts.BusinessLogicsContracts; using CarCenterContracts.SearchModels; using CarCenterContracts.StoragesContracts; using CarCenterContracts.ViewModels; +using CarCenterDataModels.Models; using System; using System.Collections.Generic; using System.Linq; @@ -108,6 +109,39 @@ namespace CarCenterBusinessLogic.BusinessLogics return true; } + public bool AddCarToInspection(InspectionSearchModel model, ICarModel car) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + + _logger.LogInformation("AddCarToInspection. InspectionName:{InspectionName}.Id:{ Id}", model.InspectionName, model.Id); + var element = _inspectionStorage.GetElement(model); + + if (element == null) + { + _logger.LogWarning("AddCarToInspection element not found"); + return false; + } + + _logger.LogInformation("AddCarToInspection find. Id:{Id}", element.Id); + + element.InspectionCars[car.Id] = car; + + _inspectionStorage.Update(new() + { + Id = element.Id, + InspectionName = element.InspectionName, + InspectionDate = element.InspectionDate, + AdministratorId = element.AdministratorId, + EmployeeId = element.EmployeeId, + InspectionCars = element.InspectionCars + }); + + return true; + } + private void CheckModel(InspectionBindingModel model, bool withParams = true) { if (model == null)