Case_accounting/CaseAccounting/CaseAccountingRestApi/Controllers/UserController.cs

66 lines
1.1 KiB
C#
Raw Normal View History

2023-05-17 23:28:43 +04:00
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.BusinessLogicContracts;
using CaseAccountingContracts.SearchModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataBaseImplement.Models;
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;
}
}
}
}