Создание временного варианта бизнес-логики
This commit is contained in:
parent
ab5606bf2f
commit
0878bff8c7
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarServiceView", "CarServic
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarServiceContracts", "CarServiceContracts\CarServiceContracts.csproj", "{98900EAA-0514-4A6B-B0D9-E2B21A089977}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarServiceBusinessLogic", "CarServiceBusinessLogic\CarServiceBusinessLogic.csproj", "{F59A4E9C-1547-472A-ADE6-313D208430E1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -21,6 +23,10 @@ Global
|
||||
{98900EAA-0514-4A6B-B0D9-E2B21A089977}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{98900EAA-0514-4A6B-B0D9-E2B21A089977}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{98900EAA-0514-4A6B-B0D9-E2B21A089977}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F59A4E9C-1547-472A-ADE6-313D208430E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F59A4E9C-1547-472A-ADE6-313D208430E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F59A4E9C-1547-472A-ADE6-313D208430E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F59A4E9C-1547-472A-ADE6-313D208430E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CustomerLogic : ICustomerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICustomerStorage _customerStorage;
|
||||
public CustomerLogic(ILogger<CustomerLogic> logger, ICustomerStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<CustomerViewModel>? ReadList(CustomerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public CustomerViewModel? ReadElement(CustomerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(CustomerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(CustomerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(CustomerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(CustomerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Customer. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ItemForRepairLogic : IItemForRepairLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IItemForRepairStorage _customerStorage;
|
||||
public ItemForRepairLogic(ILogger<ItemForRepairLogic> logger, IItemForRepairStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<ItemForRepairViewModel>? ReadList(ItemForRepairSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ItemForRepairViewModel? ReadElement(ItemForRepairSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(ItemForRepairBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ItemForRepairBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ItemForRepairBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ItemForRepairBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("ItemForRepair. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ItemLogic : IItemLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IItemStorage _customerStorage;
|
||||
public ItemLogic(ILogger<ItemLogic> logger, IItemStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<ItemViewModel>? ReadList(ItemSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ItemViewModel? ReadElement(ItemSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(ItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ItemBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ItemBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ItemBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Item. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class RepairRequestLogic : IRepairRequestLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRepairRequestStorage _customerStorage;
|
||||
public RepairRequestLogic(ILogger<RepairRequestLogic> logger, IRepairRequestStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<RepairRequestViewModel>? ReadList(RepairRequestSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public RepairRequestViewModel? ReadElement(RepairRequestSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(RepairRequestBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(RepairRequestBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(RepairRequestBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(RepairRequestBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("RepairRequest. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class VehicleLogic : IVehicleLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IVehicleStorage _customerStorage;
|
||||
public VehicleLogic(ILogger<VehicleLogic> logger, IVehicleStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<VehicleViewModel>? ReadList(VehicleSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public VehicleViewModel? ReadElement(VehicleSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(VehicleBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(VehicleBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(VehicleBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(VehicleBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Vehicle. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkInRequestLogic : IWorkInRequestLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkInRequestStorage _customerStorage;
|
||||
public WorkInRequestLogic(ILogger<WorkInRequestLogic> logger, IWorkInRequestStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<WorkInRequestViewModel>? ReadList(WorkInRequestSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public WorkInRequestViewModel? ReadElement(WorkInRequestSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(WorkInRequestBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(WorkInRequestBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(WorkInRequestBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(WorkInRequestBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("WorkInRequest. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkLogic : IWorkLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkStorage _customerStorage;
|
||||
public WorkLogic(ILogger<WorkLogic> logger, IWorkStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<WorkViewModel>? ReadList(WorkSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public WorkViewModel? ReadElement(WorkSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(WorkBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(WorkBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(WorkBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(WorkBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Work. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkPaymentLogic : IWorkPaymentLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkPaymentStorage _customerStorage;
|
||||
public WorkPaymentLogic(ILogger<WorkPaymentLogic> logger, IWorkPaymentStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<WorkPaymentViewModel>? ReadList(WorkPaymentSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public WorkPaymentViewModel? ReadElement(WorkPaymentSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(WorkPaymentBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(WorkPaymentBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(WorkPaymentBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(WorkPaymentBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("WorkPayment. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CarServiceBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class WorkerLogic : IWorkerLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IWorkerStorage _customerStorage;
|
||||
public WorkerLogic(ILogger<WorkerLogic> logger, IWorkerStorage customerStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_customerStorage = customerStorage;
|
||||
}
|
||||
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _customerStorage.GetFullList() : _customerStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public WorkerViewModel? ReadElement(WorkerSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. Id: {Id}", model.Id);
|
||||
var element = _customerStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement found. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(WorkerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(WorkerBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_customerStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(WorkerBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_customerStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(WorkerBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Worker. Id: {Id}", model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarServiceContracts\CarServiceContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -7,7 +7,7 @@ namespace CarServiceContracts.BusinessLogicsContracts
|
||||
public interface IItemForRepairLogic
|
||||
{
|
||||
List<ItemForRepairViewModel>? ReadList(ItemForRepairSearchModel? model);
|
||||
CustomerViewModel? ReadElement(ItemForRepairSearchModel model);
|
||||
ItemForRepairViewModel? ReadElement(ItemForRepairSearchModel model);
|
||||
bool Create(ItemForRepairBindingModel model);
|
||||
bool Update(ItemForRepairBindingModel model);
|
||||
bool Delete(ItemForRepairBindingModel model);
|
||||
|
@ -8,8 +8,8 @@ namespace CarServiceContracts.BusinessLogicsContracts
|
||||
{
|
||||
List<ItemViewModel>? ReadList(ItemSearchModel? model);
|
||||
ItemViewModel? ReadElement(ItemSearchModel model);
|
||||
bool Create(CustomerBindingModel model);
|
||||
bool Update(CustomerBindingModel model);
|
||||
bool Delete(CustomerBindingModel model);
|
||||
bool Create(ItemBindingModel model);
|
||||
bool Update(ItemBindingModel model);
|
||||
bool Delete(ItemBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface ICustomerStorage
|
||||
{
|
||||
List<CustomerViewModel> GetFullList();
|
||||
List<CustomerViewModel> GetFilteredList(CustomerSearchModel model);
|
||||
CustomerViewModel? GetElement(CustomerSearchModel model);
|
||||
CustomerViewModel? Insert(CustomerBindingModel model);
|
||||
CustomerViewModel? Update(CustomerBindingModel model);
|
||||
CustomerViewModel? Delete(CustomerBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IItemForRepairStorage
|
||||
{
|
||||
List<ItemForRepairViewModel> GetFullList();
|
||||
List<ItemForRepairViewModel> GetFilteredList(ItemForRepairSearchModel model);
|
||||
ItemForRepairViewModel? GetElement(ItemForRepairSearchModel model);
|
||||
ItemForRepairViewModel? Insert(ItemForRepairBindingModel model);
|
||||
ItemForRepairViewModel? Update(ItemForRepairBindingModel model);
|
||||
ItemForRepairViewModel? Delete(ItemForRepairBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IItemStorage
|
||||
{
|
||||
List<ItemViewModel> GetFullList();
|
||||
List<ItemViewModel> GetFilteredList(ItemSearchModel model);
|
||||
ItemViewModel? GetElement(ItemSearchModel model);
|
||||
ItemViewModel? Insert(ItemBindingModel model);
|
||||
ItemViewModel? Update(ItemBindingModel model);
|
||||
ItemViewModel? Delete(ItemBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IRepairRequestStorage
|
||||
{
|
||||
List<RepairRequestViewModel> GetFullList();
|
||||
List<RepairRequestViewModel> GetFilteredList(RepairRequestSearchModel model);
|
||||
RepairRequestViewModel? GetElement(RepairRequestSearchModel model);
|
||||
RepairRequestViewModel? Insert(RepairRequestBindingModel model);
|
||||
RepairRequestViewModel? Update(RepairRequestBindingModel model);
|
||||
RepairRequestViewModel? Delete(RepairRequestBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IVehicleStorage
|
||||
{
|
||||
List<VehicleViewModel> GetFullList();
|
||||
List<VehicleViewModel> GetFilteredList(VehicleSearchModel model);
|
||||
VehicleViewModel? GetElement(VehicleSearchModel model);
|
||||
VehicleViewModel? Insert(VehicleBindingModel model);
|
||||
VehicleViewModel? Update(VehicleBindingModel model);
|
||||
VehicleViewModel? Delete(VehicleBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IWorkInRequestStorage
|
||||
{
|
||||
List<WorkInRequestViewModel> GetFullList();
|
||||
List<WorkInRequestViewModel> GetFilteredList(WorkInRequestSearchModel model);
|
||||
WorkInRequestViewModel? GetElement(WorkInRequestSearchModel model);
|
||||
WorkInRequestViewModel? Insert(WorkInRequestBindingModel model);
|
||||
WorkInRequestViewModel? Update(WorkInRequestBindingModel model);
|
||||
WorkInRequestViewModel? Delete(WorkInRequestBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IWorkPaymentStorage
|
||||
{
|
||||
List<WorkPaymentViewModel> GetFullList();
|
||||
List<WorkPaymentViewModel> GetFilteredList(WorkPaymentSearchModel model);
|
||||
WorkPaymentViewModel? GetElement(WorkPaymentSearchModel model);
|
||||
WorkPaymentViewModel? Insert(WorkPaymentBindingModel model);
|
||||
WorkPaymentViewModel? Update(WorkPaymentBindingModel model);
|
||||
WorkPaymentViewModel? Delete(WorkPaymentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IWorkStorage
|
||||
{
|
||||
List<WorkViewModel> GetFullList();
|
||||
List<WorkViewModel> GetFilteredList(WorkSearchModel model);
|
||||
WorkViewModel? GetElement(WorkSearchModel model);
|
||||
WorkViewModel? Insert(WorkBindingModel model);
|
||||
WorkViewModel? Update(WorkBindingModel model);
|
||||
WorkViewModel? Delete(WorkBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using CarServiceContracts.BindingModels;
|
||||
using CarServiceContracts.SearchModels;
|
||||
using CarServiceContracts.ViewModels;
|
||||
|
||||
namespace CarServiceContracts.StorageContracts
|
||||
{
|
||||
public interface IWorkerStorage
|
||||
{
|
||||
List<WorkerViewModel> GetFullList();
|
||||
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
|
||||
WorkerViewModel? GetElement(WorkerSearchModel model);
|
||||
WorkerViewModel? Insert(WorkerBindingModel model);
|
||||
WorkerViewModel? Update(WorkerBindingModel model);
|
||||
WorkerViewModel? Delete(WorkerBindingModel model);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user