diff --git a/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj b/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj index 2c33b1c..ea3630b 100644 --- a/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj +++ b/ComputerShopImplementerApp/ComputerShopImplementerApp.csproj @@ -7,7 +7,11 @@ - + + + + + diff --git a/ComputerShopImplementerApp/Models/ErrorViewModel.cs b/ComputerShopImplementerApp/Models/ErrorViewModel.cs new file mode 100644 index 0000000..4ee0f60 --- /dev/null +++ b/ComputerShopImplementerApp/Models/ErrorViewModel.cs @@ -0,0 +1,9 @@ +namespace ComputerShopImplementerApp.Models +{ + public class ErrorViewModel + { + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + } +} diff --git a/ComputerShopImplementerApp/appsettings.json b/ComputerShopImplementerApp/appsettings.json index 10f68b8..91026f2 100644 --- a/ComputerShopImplementerApp/appsettings.json +++ b/ComputerShopImplementerApp/appsettings.json @@ -5,5 +5,6 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "IpAddress": "http://localhost:5055" } diff --git a/ComputerShopRestApi/ComputerShopRestApi.csproj b/ComputerShopRestApi/ComputerShopRestApi.csproj index 2c33b1c..20cc73d 100644 --- a/ComputerShopRestApi/ComputerShopRestApi.csproj +++ b/ComputerShopRestApi/ComputerShopRestApi.csproj @@ -10,4 +10,10 @@ + + + + + + diff --git a/ComputerShopRestApi/Controllers/UserController.cs b/ComputerShopRestApi/Controllers/UserController.cs new file mode 100644 index 0000000..4de7c31 --- /dev/null +++ b/ComputerShopRestApi/Controllers/UserController.cs @@ -0,0 +1,40 @@ +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.SearchModels; +using ComputerShopContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace ComputerShopRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class UserController : Controller + { + private readonly ILogger _logger; + private readonly IUserLogic _logic; + + public UserController(IUserLogic logic, ILogger logger) + { + _logic = logic; + _logger = logger; + } + + [HttpGet] + public UserViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new UserSearchModel + { + Login = login, + Email = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + } +}