слой бизнес логики, изменения в SearchModels
This commit is contained in:
parent
2d75dc699e
commit
a93d78d901
@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.4.33110.190
|
VisualStudioVersion = 17.4.33110.190
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryDataModels", "FactoryDataModels\FactoryDataModels.csproj", "{CBE4843B-F023-4C97-925E-BEFE960D0EEA}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryDataModels", "FactoryDataModels\FactoryDataModels.csproj", "{CBE4843B-F023-4C97-925E-BEFE960D0EEA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryContracts", "FactoryContracts\FactoryContracts.csproj", "{87BA79A9-CF35-4CB4-98BD-86C01918C81C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FactoryContracts", "FactoryContracts\FactoryContracts.csproj", "{87BA79A9-CF35-4CB4-98BD-86C01918C81C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FactoryBuisinessLogic", "FactoryBuisinessLogic\FactoryBuisinessLogic.csproj", "{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -21,6 +23,10 @@ Global
|
|||||||
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{87BA79A9-CF35-4CB4-98BD-86C01918C81C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EA960B3E-6BFB-4B16-9B0A-E1D603967FEC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
119
Factory/FactoryBuisinessLogic/BusinessLogics/ClientLogic.cs
Normal file
119
Factory/FactoryBuisinessLogic/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using FactoryContracts.BindingModels;
|
||||||
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FactoryContracts.SearchModels;
|
||||||
|
using FactoryContracts.StoragesContracts;
|
||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ClientLogic : IClientLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
|
public ClientLogic(ILogger<ExecutionPhaseLogic> logger, IClientStorage clientStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Login:{Login}. Id:{Id}", model?.Login, model?.Id);
|
||||||
|
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Login:{Login}. Id:{Id}", model.Login, model.Id);
|
||||||
|
var element = _clientStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_clientStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Login))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет логина клиента", nameof(model.Login));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Email));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Client. Login:{Login}. Email:{Email}. Password:{Password}.", model.Login, model.Email, model.Password);
|
||||||
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Login = model.Login
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Клиент с таким логином уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
using FactoryContracts.BindingModels;
|
||||||
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FactoryContracts.SearchModels;
|
||||||
|
using FactoryContracts.StoragesContracts;
|
||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
using FactoryDataModels.Enums;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ExecutionPhaseLogic : IExecutionPhaseLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IExecutionPhaseStorage _executionPhaseStorage;
|
||||||
|
|
||||||
|
public ExecutionPhaseLogic(ILogger<ExecutionPhaseLogic> logger, IExecutionPhaseStorage executionPhaseStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_executionPhaseStorage = executionPhaseStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ExecutionPhaseViewModel>? ReadList(ExecutionPhaseSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ExecutionPhaseName:{ExecutionPhaseName}. Id:{Id}", model?.ExecutionPhaseName, model?.Id);
|
||||||
|
var list = model == null ? _executionPhaseStorage.GetFullList() : _executionPhaseStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExecutionPhaseViewModel? ReadElement(ExecutionPhaseSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ExecutionPhaseName:{ExecutionPhaseName}. Id:{Id}", model.ExecutionPhaseName, model.Id);
|
||||||
|
var element = _executionPhaseStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ExecutionPhaseBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_executionPhaseStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ExecutionPhaseBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_executionPhaseStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ExecutionPhaseBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_executionPhaseStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ExecutionPhaseBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ExecutionPhaseName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия этапа выполнения", nameof(model.ExecutionPhaseName));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ImplementerFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет ФИО исполнителя", nameof(model.ImplementerFIO));
|
||||||
|
}
|
||||||
|
if (model.Status == ExecutionPhaseStatus.Неизвестен)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Состояние этапа не может быть неизвестно", nameof(model.Status));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ExecutionPhase. ExecutionPhaseName:{ExecutionPhaseName}. ImplementerFIO:{ImplementerFIO}. Status:{Status}. Id:{Id}", model.ExecutionPhaseName, model.ImplementerFIO, model.Status, model.Id);
|
||||||
|
var element = _executionPhaseStorage.GetElement(new ExecutionPhaseSearchModel
|
||||||
|
{
|
||||||
|
ExecutionPhaseName = model.ExecutionPhaseName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Этап с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
using FactoryContracts.BindingModels;
|
||||||
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FactoryContracts.SearchModels;
|
||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
using FactoryContracts.StoragesContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class PlanProductionLogic : IPlanProductionLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IPlanProductionStorage _planProductionStorage;
|
||||||
|
public PlanProductionLogic(ILogger<PlanProductionLogic> logger, IPlanProductionStorage planProductionStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_planProductionStorage = planProductionStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlanProductionViewModel>? ReadList(PlanProductionSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ProductionName:{ProductionName}. Id:{Id}", model?.ProductionName, model?.Id);
|
||||||
|
var list = model == null ? _planProductionStorage.GetFullList() : _planProductionStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlanProductionViewModel? ReadElement(PlanProductionSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ProductionName:{ProductionName}. Id:{Id}", model.ProductionName, model.Id);
|
||||||
|
var element = _planProductionStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(PlanProductionBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_planProductionStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(PlanProductionBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_planProductionStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(PlanProductionBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_planProductionStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(PlanProductionBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ProductionName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия плана производства", nameof(model.ProductionName));
|
||||||
|
}
|
||||||
|
if (model.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Количество должно быть больше 0", nameof(model.Count));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("PlanProduction. ProductionName:{ProductionName}. Count:{Count}. Id:{Id}", model.ProductionName, model.Count, model.Id);
|
||||||
|
var element = _planProductionStorage.GetElement(new PlanProductionSearchModel
|
||||||
|
{
|
||||||
|
ProductionName = model.ProductionName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("План производства с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
116
Factory/FactoryBuisinessLogic/BusinessLogics/WorkLogic.cs
Normal file
116
Factory/FactoryBuisinessLogic/BusinessLogics/WorkLogic.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using FactoryContracts.BindingModels;
|
||||||
|
using FactoryContracts.BusinessLogicsContracts;
|
||||||
|
using FactoryContracts.SearchModels;
|
||||||
|
using FactoryContracts.StoragesContracts;
|
||||||
|
using FactoryContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace FactoryBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class WorkpieceLogic : IWorkpieceLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IWorkpieceStorage _workpieceStorage;
|
||||||
|
public WorkpieceLogic(ILogger<ExecutionPhaseLogic> logger, IWorkpieceStorage workpieceStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_workpieceStorage = workpieceStorage;
|
||||||
|
}
|
||||||
|
public bool Create(WorkpieceBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workpieceStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(WorkpieceBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_workpieceStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(WorkpieceBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_workpieceStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkpieceViewModel? ReadElement(WorkpieceSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. WorkpieceName:{WorkpieceName}. Id:{Id}", model.WorkpieceName, model.Id);
|
||||||
|
var element = _workpieceStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WorkpieceViewModel>? ReadList(WorkpieceSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. WorkpieceName:{WorkpieceName}. Id:{Id}", model?.WorkpieceName, model?.Id);
|
||||||
|
var list = model == null ? _workpieceStorage.GetFullList() : _workpieceStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(WorkpieceBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.WorkpieceName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия заготовки", nameof(model.WorkpieceName));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Material))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет материала для заготовки", nameof(model.Material));
|
||||||
|
}
|
||||||
|
if (model.Cost <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Цена заготовки должна быть больше 0", nameof(model.Cost));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Component. WorkpieceName:{WorkpieceName}. Material:{Material}. Cost:{Cost}. Id:{Id}", model.WorkpieceName, model.Material, model.Cost, model.Id);
|
||||||
|
var element = _workpieceStorage.GetElement(new WorkpieceSearchModel
|
||||||
|
{
|
||||||
|
WorkpieceName = model.WorkpieceName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Заготовка с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
Factory/FactoryBuisinessLogic/FactoryBuisinessLogic.csproj
Normal file
17
Factory/FactoryBuisinessLogic/FactoryBuisinessLogic.csproj
Normal file
@ -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="8.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\FactoryContracts\FactoryContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -7,6 +7,7 @@ namespace FactoryContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string ExecutionPhaseName { get; set; } = string.Empty;
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
|
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
@ -9,12 +9,10 @@ namespace FactoryContracts.BusinessLogicsContracts
|
|||||||
List<PlanProductionViewModel>? ReadList(PlanProductionSearchModel? model);
|
List<PlanProductionViewModel>? ReadList(PlanProductionSearchModel? model);
|
||||||
PlanProductionViewModel? ReadElement(PlanProductionSearchModel model);
|
PlanProductionViewModel? ReadElement(PlanProductionSearchModel model);
|
||||||
|
|
||||||
bool CreatePlanProduction(PlanProductionBindingModel model);
|
bool Create(PlanProductionBindingModel model);
|
||||||
|
|
||||||
bool TakePlanProductionInWork(PlanProductionBindingModel model);
|
bool Update(PlanProductionBindingModel model);
|
||||||
|
|
||||||
bool FinishPlanProduction(PlanProductionBindingModel model);
|
bool Delete(PlanProductionBindingModel model);
|
||||||
|
|
||||||
bool DeliveryPlanProduction(PlanProductionBindingModel model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,8 +4,6 @@
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? ImplementerFIO { get; set; }
|
public string? ExecutionPhaseName { get; set; }
|
||||||
|
|
||||||
public string? Password { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,5 +5,6 @@ namespace FactoryContracts.SearchModels
|
|||||||
public class PlanProductionSearchModel
|
public class PlanProductionSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public string? ProductionName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,6 @@
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
|
||||||
public string? WorkName { get; set; }
|
public string? WorkpieceName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,10 +12,10 @@ namespace FactoryContracts.StoragesContracts
|
|||||||
|
|
||||||
PlanProductionViewModel? GetElement(PlanProductionSearchModel model);
|
PlanProductionViewModel? GetElement(PlanProductionSearchModel model);
|
||||||
|
|
||||||
PlanProductionViewModel? Insert(ExecutionPhaseBindingModel model);
|
PlanProductionViewModel? Insert(PlanProductionBindingModel model);
|
||||||
|
|
||||||
PlanProductionViewModel? Update(ExecutionPhaseBindingModel model);
|
PlanProductionViewModel? Update(PlanProductionBindingModel model);
|
||||||
|
|
||||||
PlanProductionViewModel? Delete(ExecutionPhaseBindingModel model);
|
PlanProductionViewModel? Delete(PlanProductionBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,9 +10,12 @@ namespace FactoryContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("ФИО исполнителя")]
|
[DisplayName("ФИО исполнителя")]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Описание этапа")]
|
||||||
|
public string ExecutionPhaseName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Статус этапа")]
|
[DisplayName("Статус")]
|
||||||
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
|
public ExecutionPhaseStatus Status { get; set; } = ExecutionPhaseStatus.Неизвестен;
|
||||||
|
|
||||||
[DisplayName("Номер клиента")]
|
[DisplayName("Номер клиента")]
|
||||||
public int ClientId { get; set; }
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ namespace FactoryDataModels.Models
|
|||||||
{
|
{
|
||||||
public interface IExecutionPhaseModel : IId
|
public interface IExecutionPhaseModel : IId
|
||||||
{
|
{
|
||||||
|
|
||||||
|
string ExecutionPhaseName { get; }
|
||||||
string ImplementerFIO { get; }
|
string ImplementerFIO { get; }
|
||||||
ExecutionPhaseStatus Status { get; }
|
ExecutionPhaseStatus Status { get; }
|
||||||
int ClientId { get; }
|
int ClientId { get; }
|
||||||
|
Loading…
Reference in New Issue
Block a user