using BarContracts.BindingModels; using BarContracts.BusinessLogicContracts; using BarContracts.SearchModels; using BarContracts.ViewModels; using Microsoft.AspNetCore.Mvc; namespace BarRestApi.Controllers { [Route("api/[controller]/[action]")] [ApiController] public class ClientController : Controller { private readonly ILogger _logger; private readonly IClientLogic _clientLogic; public ClientController(IClientLogic ClientLogic, ILogger Logger) { _logger = Logger; _clientLogic = ClientLogic; } [HttpGet] public ClientViewModel? Login(string Login, string Password) { try { return _clientLogic.ReadElement(new ClientSearchModel { Email = Login, Password = Password }); } catch (Exception ex) { _logger.LogError(ex, "Ошибка входа в систему"); throw; } } [HttpPost] public void Register(ClientBindingModel Model) { try { _clientLogic.Create(Model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка регистрации"); throw; } } [HttpPost] public void UpdateData(ClientBindingModel Model) { try { _clientLogic.Update(Model); } catch (Exception ex) { _logger.LogError(ex, "Ошибка обновления данных"); throw; } } } }