кто такие фиксики
This commit is contained in:
parent
0054d6550a
commit
38196534b9
@ -0,0 +1,99 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class DescriptionProcedureController : Controller
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDescriptionProcedureLogic _guidance;
|
||||
|
||||
public DescriptionProcedureController(ILogger<DescriptionProcedureController> logger,
|
||||
IDescriptionProcedureLogic guidance)
|
||||
{
|
||||
_logger = logger;
|
||||
_guidance = guidance;
|
||||
}
|
||||
[HttpGet]
|
||||
public DescriptionProcedureViewModel GetGuidance(int guidanceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _guidance.ReadElement(new DescriptionProcedureSearchModel { Id = guidanceId });
|
||||
return elem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения рекомендации по id={Id}", guidanceId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<DescriptionProcedureViewModel>? GetGuidances(int? serviceId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!serviceId.HasValue)
|
||||
return _guidance.ReadList(null);
|
||||
return _guidance.ReadList(new DescriptionProcedureSearchModel
|
||||
{
|
||||
DescriptionProcedureId = serviceId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка рекомендааций услуги id ={ Id}", serviceId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateGuidance(DescriptionProcedureBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_guidance.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания рекомендации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateGuidance(DescriptionProcedureBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _guidance.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить рекомендацию");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteGuidance(DescriptionProcedureBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _guidance.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления рекомендации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
105
Hospital/HospitalRestApi/Controllers/ProcedureController.cs
Normal file
105
Hospital/HospitalRestApi/Controllers/ProcedureController.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.BusinessLogicContracts;
|
||||
using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace HospitalRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ProcedureController : Controller
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProcedureLogic _service;
|
||||
public ProcedureController(ILogger<ProcedureController> logger, IProcedureLogic service)
|
||||
{
|
||||
_logger = logger;
|
||||
_service = service;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public Tuple<ProcedureViewModel, List<string>>? GetService(int serviceId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var elem = _service.ReadElement(new ProcedureSearchModel { Id = serviceId });
|
||||
if (elem == null)
|
||||
return null;
|
||||
var res = Tuple.Create(elem, elem.ProcedureMedicines.Select(x => x.Value.Name).ToList());
|
||||
res.Item1.ProcedureMedicines = null!;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения услуги по id={Id}", serviceId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ProcedureViewModel> GetServices(int? pharmacistId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ProcedureViewModel> res;
|
||||
if (!pharmacistId.HasValue)
|
||||
res = _service.ReadList(null);
|
||||
else
|
||||
res = _service.ReadList(new ProcedureSearchModel { PharmacistId = pharmacistId });
|
||||
foreach (var service in res)
|
||||
service.ProcedureMedicines = null;
|
||||
return res;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка услуг");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool CreateService(ProcedureBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось создать услугу");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool UpdateService(ProcedureBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Не удалось обновить услугу");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public bool DeleteService(ProcedureBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _service.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления услуги");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user