SUBD-Petrushin-Egor-PIbd-22/TaskTrackerRestApi/Controllers/ClientController.cs
2024-05-13 14:29:34 +04:00

65 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using TaskTrackerContracts.BindingModels;
using TaskTrackerContracts.BusinessLogicsContracts;
using TaskTrackerContracts.SearchModels;
using TaskTrackerContracts.ViewModels;
namespace TaskTrackerRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller
{
private readonly IUserLogic _logic;
public ClientController(IUserLogic logic)
{
_logic = logic;
}
[HttpGet]
public UserViewModel? Login(string login, string password)
{
try
{
return _logic.ReadElement(new UserSearchModel
{
Email = login,
Password = password
});
}
catch
{
throw;
}
}
[HttpPost]
public void Register(UserBindingModel model)
{
try
{
_logic.Create(model);
}
catch
{
throw;
}
}
[HttpPost]
public void UpdateData(UserBindingModel model)
{
try
{
_logic.Update(model);
}
catch
{
throw;
}
}
}
}