Case_accounting/CaseAccounting/CaseAccountingRestApi/Controllers/UserController.cs
2023-05-18 01:15:02 +04:00

67 lines
1.1 KiB
C#

using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataBaseImplement.Models;
using CaseAccountingDataModels.Enum;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class UserController : Controller
{
private readonly IUserLogic _logic;
public UserController(IUserLogic logic)
{
_logic = logic;
}
[HttpGet]
public UserViewModel? Login(string login, string password, Role role)
{
try
{
return _logic.ReadElement(new UserSearchModel
{
Login = login,
Password = password,
Role = role
});
}
catch (Exception)
{
throw;
}
}
[HttpPost]
public void Register(UserBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception)
{
throw;
}
}
[HttpPost]
public void UpdateData(UserBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception)
{
throw;
}
}
}
}