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 ApothecaryController : ControllerBase { private readonly ILogger _logger; private readonly IApothecaryLogic _logic; public ApothecaryController(IApothecaryLogic logic, ILogger logger) { _logger = logger; _logic = logic; } [HttpGet] public ApothecaryViewModel? Login(string login, string password) { try { return _logic.ReadElement(new ApothecarySearchModel { Login = login, Password = password }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка входа в систему"); throw; } } [HttpPost] public void Register(ApothecaryBindingModel model) { try { _logic.Create(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка регистрации"); throw; } } [HttpPost] public void UpdateData(ApothecaryBindingModel model) { try { _logic.Update(model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка обновления данных"); throw; } } } }