добавлен контроллер
This commit is contained in:
parent
289697c26d
commit
cbbd31f096
@ -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<ClientController> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,10 +11,6 @@
|
|||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Controllers\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj" />
|
<ProjectReference Include="..\HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj" />
|
||||||
<ProjectReference Include="..\HardwareShopContracts\HardwareShopContracts.csproj" />
|
<ProjectReference Include="..\HardwareShopContracts\HardwareShopContracts.csproj" />
|
||||||
|
Loading…
Reference in New Issue
Block a user