еще немного правок

This commit is contained in:
Alenka 2024-05-01 17:50:41 +04:00
parent d864c43932
commit 935bb0b08b
6 changed files with 72 additions and 75 deletions

View File

@ -17,12 +17,12 @@ namespace HospitalBusinessLogic.BusinessLogics
{
private readonly ILogger _logger;
private readonly IDescriptionProcedureStorage _guidanceStorage;
private readonly IDescriptionProcedureStorage _descriptionProcedureStorage;
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage guidanceStorage)
public DescriptionProcedureLogic(ILogger<DescriptionProcedureLogic> logger, IDescriptionProcedureStorage descriptionProcedureStorage)
{
_logger = logger;
_guidanceStorage = guidanceStorage;
_descriptionProcedureStorage = descriptionProcedureStorage;
}
public DescriptionProcedureViewModel? ReadElement(DescriptionProcedureSearchModel model)
@ -32,7 +32,7 @@ namespace HospitalBusinessLogic.BusinessLogics
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{ Id}", model.Id);
var element = _guidanceStorage.GetElement(model);
var element = _descriptionProcedureStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
@ -45,8 +45,8 @@ namespace HospitalBusinessLogic.BusinessLogics
public List<DescriptionProcedureViewModel>? ReadList(DescriptionProcedureSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
var list = model == null ? _guidanceStorage.GetFullList() :
_guidanceStorage.GetFilteredList(model);
var list = model == null ? _descriptionProcedureStorage.GetFullList() :
_descriptionProcedureStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@ -59,7 +59,7 @@ namespace HospitalBusinessLogic.BusinessLogics
public bool Create(DescriptionProcedureBindingModel model)
{
CheckModel(model);
if (_guidanceStorage.Insert(model) == null)
if (_descriptionProcedureStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
@ -69,7 +69,7 @@ namespace HospitalBusinessLogic.BusinessLogics
public bool Update(DescriptionProcedureBindingModel model)
{
CheckModel(model);
if (_guidanceStorage.Update(model) == null)
if (_descriptionProcedureStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
@ -80,7 +80,7 @@ namespace HospitalBusinessLogic.BusinessLogics
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_guidanceStorage.Delete(model) == null)
if (_descriptionProcedureStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
@ -104,7 +104,7 @@ namespace HospitalBusinessLogic.BusinessLogics
nameof(model.Description));
}
_logger.LogInformation("Guidance. Text:{Text}.", model.Description);
_logger.LogInformation("descriptionProcedure. Text:{Text}.", model.Description);
}
}
}

View File

@ -99,12 +99,12 @@ true)
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия медикамента",
throw new ArgumentNullException("Нет названия лекарства",
nameof(model.Name));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена медикамента должна быть больше 0", nameof(model.Price));
throw new ArgumentNullException("Цена лекарства должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Medicine. Medicine:{MedicineName}. Price:{ Price }. Id: { Id}", model.Name, model.Price, model.Id);
var element = _medicineStorage.GetElement(new MedicineSearchModel
@ -113,7 +113,7 @@ true)
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Медикамент с таким названием уже есть");
throw new InvalidOperationException("Лекарство с таким названием уже есть");
}
}
}

View File

@ -16,18 +16,18 @@ namespace HospitalBusinessLogic.BusinessLogics
public class ProcedureLogic : IProcedureLogic
{
private readonly ILogger _logger;
private readonly IProcedureStorage _serviceStorage;
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage serviceStorage)
private readonly IProcedureStorage _procedureStorage;
public ProcedureLogic(ILogger<ProcedureLogic> logger, IProcedureStorage procedureStorage)
{
_logger = logger;
_serviceStorage = serviceStorage;
_procedureStorage = procedureStorage;
}
public List<ProcedureViewModel>? ReadList(ProcedureSearchModel? model)
{
_logger.LogInformation("ReadList. ServiceName:{ServiceName}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _serviceStorage.GetFullList() :
_serviceStorage.GetFilteredList(model);
_logger.LogInformation("ReadList. ProcedureName:{ProcedureName}. Id:{ Id}", model?.Name, model?.Id);
var list = model == null ? _procedureStorage.GetFullList() :
_procedureStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
@ -42,8 +42,8 @@ _serviceStorage.GetFilteredList(model);
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ServiceName:{ServiceName}.Id:{ Id}", model.Name, model.Id);
var element = _serviceStorage.GetElement(model);
_logger.LogInformation("ReadElement. ProcedureName:{ProcedureName}.Id:{ Id}", model.Name, model.Id);
var element = _procedureStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
@ -56,7 +56,7 @@ _serviceStorage.GetFilteredList(model);
public bool Create(ProcedureBindingModel model)
{
CheckModel(model);
if (_serviceStorage.Insert(model) == null)
if (_procedureStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
@ -67,7 +67,7 @@ _serviceStorage.GetFilteredList(model);
public bool Update(ProcedureBindingModel model)
{
CheckModel(model);
if (_serviceStorage.Update(model) == null)
if (_procedureStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
@ -78,7 +78,7 @@ _serviceStorage.GetFilteredList(model);
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_serviceStorage.Delete(model) == null)
if (_procedureStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
@ -102,12 +102,9 @@ true)
throw new ArgumentNullException("Нет названия услуги",
nameof(model.Name));
}
//if (model.Price <= 0)
{
// throw new ArgumentNullException("Цена мороженного услуги быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Service. ServiceName:{ServiceName}. Id: { Id}", model.Name, model.Id);
var element = _serviceStorage.GetElement(new ProcedureSearchModel
_logger.LogInformation("Procedure. ProcedureName:{ProcedureName}. Id: { Id}", model.Name, model.Id);
var element = _procedureStorage.GetElement(new ProcedureSearchModel
{
Name = model.Name
});

View File

@ -13,67 +13,67 @@ namespace HospitalRestApi.Controllers
{
private readonly ILogger _logger;
private readonly IDescriptionProcedureLogic _guidance;
private readonly IDescriptionProcedureLogic _descriptionProcedure;
public DescriptionProcedureController(ILogger<DescriptionProcedureController> logger,
IDescriptionProcedureLogic guidance)
IDescriptionProcedureLogic descriptionProceduree)
{
_logger = logger;
_guidance = guidance;
_descriptionProcedure = descriptionProceduree;
}
[HttpGet]
public DescriptionProcedureViewModel GetGuidance(int guidanceId)
public DescriptionProcedureViewModel GetDescriptionProcedure(int descriptionProcedureId)
{
try
{
var elem = _guidance.ReadElement(new DescriptionProcedureSearchModel { Id = guidanceId });
var elem = _descriptionProcedure.ReadElement(new DescriptionProcedureSearchModel { Id = descriptionProcedureId });
return elem;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения рекомендации по id={Id}", guidanceId);
_logger.LogError(ex, "Ошибка получения описании по id={Id}", descriptionProcedureId);
throw;
}
}
[HttpGet]
public List<DescriptionProcedureViewModel>? GetGuidances(int? serviceId = null)
public List<DescriptionProcedureViewModel>? GetDescriptionProcedurees(int? procedureId = null)
{
try
{
if (!serviceId.HasValue)
return _guidance.ReadList(null);
return _guidance.ReadList(new DescriptionProcedureSearchModel
if (!procedureId.HasValue)
return _descriptionProcedure.ReadList(null);
return _descriptionProcedure.ReadList(new DescriptionProcedureSearchModel
{
PharmacistId = serviceId
PharmacistId = procedureId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка рекомендааций услуги id ={ Id}", serviceId);
_logger.LogError(ex, "Ошибка получения списка рекомендааций процедуры id ={ Id}", procedureId);
throw;
}
}
[HttpPost]
public void CreateGuidance(DescriptionProcedureBindingModel model)
public void CreateDescriptionProceduree(DescriptionProcedureBindingModel model)
{
try
{
_guidance.Create(model);
_descriptionProcedure.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания рекомендации");
_logger.LogError(ex, "Ошибка создания описании");
throw;
}
}
[HttpPost]
public bool UpdateGuidance(DescriptionProcedureBindingModel model)
public bool UpdateDescriptionProceduree(DescriptionProcedureBindingModel model)
{
try
{
return _guidance.Update(model);
return _descriptionProcedure.Update(model);
}
catch (Exception ex)
{
@ -83,15 +83,15 @@ namespace HospitalRestApi.Controllers
}
[HttpPost]
public bool DeleteGuidance(DescriptionProcedureBindingModel model)
public bool DeleteDescriptionProceduree(DescriptionProcedureBindingModel model)
{
try
{
return _guidance.Delete(model);
return _descriptionProcedure.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления рекомендации");
_logger.LogError(ex, "Ошибка удаления описании");
throw;
}
}

View File

@ -34,7 +34,7 @@ namespace HospitalRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения медикамента по id={Id}", medicineId);
_logger.LogError(ex, "Ошибка получения лекарства по id={Id}", medicineId);
throw;
}
}
@ -54,7 +54,7 @@ namespace HospitalRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка медикаментов");
_logger.LogError(ex, "Ошибка получения списка лекарств");
throw;
}
}
@ -67,7 +67,7 @@ namespace HospitalRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Не удалось создать медикамент");
_logger.LogError(ex, "Не удалось создать лекарство");
throw;
}
}
@ -83,7 +83,7 @@ namespace HospitalRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Не удалось обновить магазин");
_logger.LogError(ex, "Не удалось обновить лекарство");
throw;
}
}
@ -97,7 +97,7 @@ namespace HospitalRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления магазина");
_logger.LogError(ex, "Ошибка удаления лекарства");
throw;
}
}

View File

@ -13,19 +13,19 @@ namespace HospitalRestApi.Controllers
{
private readonly ILogger _logger;
private readonly IProcedureLogic _service;
public ProcedureController(ILogger<ProcedureController> logger, IProcedureLogic service)
private readonly IProcedureLogic _procedure;
public ProcedureController(ILogger<ProcedureController> logger, IProcedureLogic procedure)
{
_logger = logger;
_service = service;
_procedure = procedure;
}
[HttpGet]
public Tuple<ProcedureViewModel, List<string>>? GetService(int serviceId)
public Tuple<ProcedureViewModel, List<string>>? GetProcedure(int ProcedureId)
{
try
{
var elem = _service.ReadElement(new ProcedureSearchModel { Id = serviceId });
var elem = _procedure.ReadElement(new ProcedureSearchModel { Id = ProcedureId });
if (elem == null)
return null;
var res = Tuple.Create(elem, elem.ProcedureMedicines.Select(x => x.Value.Name).ToList());
@ -34,22 +34,22 @@ namespace HospitalRestApi.Controllers
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения услуги по id={Id}", serviceId);
_logger.LogError(ex, "Ошибка получения процедуры по id={Id}", ProcedureId);
throw;
}
}
[HttpGet]
public List<ProcedureViewModel> GetServices(int? pharmacistId = null)
public List<ProcedureViewModel> GetProcedures(int? pharmacistId = null)
{
try
{
List<ProcedureViewModel> res;
if (!pharmacistId.HasValue)
res = _service.ReadList(null);
res = _procedure.ReadList(null);
else
res = _service.ReadList(new ProcedureSearchModel { PharmacistId = pharmacistId });
foreach (var service in res)
service.ProcedureMedicines = null;
res = _procedure.ReadList(new ProcedureSearchModel { PharmacistId = pharmacistId });
foreach (var Procedure in res)
Procedure.ProcedureMedicines = null;
return res;
}
catch (Exception ex)
@ -59,43 +59,43 @@ namespace HospitalRestApi.Controllers
}
}
[HttpPost]
public bool CreateService(ProcedureBindingModel model)
public bool CreateProcedure(ProcedureBindingModel model)
{
try
{
return _service.Create(model);
return _procedure.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Не удалось создать услугу");
_logger.LogError(ex, "Не удалось создать процедуру");
throw;
}
}
[HttpPost]
public bool UpdateService(ProcedureBindingModel model)
public bool UpdateProcedure(ProcedureBindingModel model)
{
try
{
return _service.Update(model);
return _procedure.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Не удалось обновить услугу");
_logger.LogError(ex, "Не удалось обновить процедуру");
throw;
}
}
[HttpPost]
public bool DeleteService(ProcedureBindingModel model)
public bool DeleteProcedure(ProcedureBindingModel model)
{
try
{
return _service.Delete(model);
return _procedure.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления услуги");
_logger.LogError(ex, "Ошибка удаления процедуры");
throw;
}
}