Merge branch 'CarCenter' of https://git.is.ulstu.ru/spacyboy/CourseWork_CarCenter into CarCenter
This commit is contained in:
@@ -3,6 +3,7 @@ using CarCenterContracts.BusinessLogicsContracts;
|
|||||||
using CarCenterContracts.SearchModels;
|
using CarCenterContracts.SearchModels;
|
||||||
using CarCenterContracts.StoragesContracts;
|
using CarCenterContracts.StoragesContracts;
|
||||||
using CarCenterContracts.ViewModels;
|
using CarCenterContracts.ViewModels;
|
||||||
|
using CarCenterDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -107,6 +108,39 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
|||||||
return true;
|
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)
|
private void CheckModel(EquipmentBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using CarCenterContracts.BusinessLogicsContracts;
|
|||||||
using CarCenterContracts.SearchModels;
|
using CarCenterContracts.SearchModels;
|
||||||
using CarCenterContracts.StoragesContracts;
|
using CarCenterContracts.StoragesContracts;
|
||||||
using CarCenterContracts.ViewModels;
|
using CarCenterContracts.ViewModels;
|
||||||
|
using CarCenterDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -108,6 +109,39 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
|||||||
return true;
|
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)
|
private void CheckModel(InspectionBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user