From cbbd31f09618cdc833042ca507920e5b548b6245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9?= Date: Sat, 1 Apr 2023 22:18:09 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BA=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5?= =?UTF-8?q?=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ClientController.cs | 55 +++++++++++++++++++ .../HardwareShopRestApi.csproj | 4 -- 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs diff --git a/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs b/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs new file mode 100644 index 0000000..8041bad --- /dev/null +++ b/HardwareShop/HardwareShopRestApi/Controllers/ClientController.cs @@ -0,0 +1,55 @@ +using HardwareShopContracts.BindingModels; +using HardwareShopContracts.BusinessLogicsContracts; +using HardwareShopContracts.SearchModels; +using HardwareShopContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace HardwareShopRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ClientController : Controller + { + private readonly ILogger _logger; + + private readonly IUserLogic _logic; + + public ClientController(IUserLogic logic, ILogger logger) + { + _logger = logger; + _logic = logic; + } + + [HttpGet] + public UserViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new UserSearchModel + { + Email = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + [HttpPost] + public void Register(UserBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка регистрации"); + throw; + } + } + } +} \ No newline at end of file diff --git a/HardwareShop/HardwareShopRestApi/HardwareShopRestApi.csproj b/HardwareShop/HardwareShopRestApi/HardwareShopRestApi.csproj index 40effd1..8e97e82 100644 --- a/HardwareShop/HardwareShopRestApi/HardwareShopRestApi.csproj +++ b/HardwareShop/HardwareShopRestApi/HardwareShopRestApi.csproj @@ -11,10 +11,6 @@ - - - -