изменила бизнес логику

This commit is contained in:
Nastya_Kozlova 2024-04-28 19:05:25 +04:00
parent 057d088443
commit 03a7c2a36b
2 changed files with 68 additions and 0 deletions

View File

@ -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)

View File

@ -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)