Merge branch 'main' of https://git.is.ulstu.ru/antic0der/PIbd-23_Nasyrov_A_Yunusov_N_CourseWork_Veterinary
This commit is contained in:
commit
1e139daa5f
@ -0,0 +1,65 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using VeterinaryContracts.BindingModels;
|
||||
using VeterinaryContracts.BusinessLogicContracts;
|
||||
using VeterinaryContracts.SearchModels;
|
||||
using VeterinaryContracts.ViewModels;
|
||||
|
||||
namespace VeterinaryRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class OwnerController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOwnerLogic _logic;
|
||||
public OwnerController(IOwnerLogic logic, ILogger<OwnerController>
|
||||
logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
[HttpGet]
|
||||
public OwnerViewModel? Login(string login, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new OwnerSearchModel
|
||||
{
|
||||
Login = login,
|
||||
Password = password
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void Register(OwnerBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка регистрации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateData(OwnerBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления данных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace VeterinaryRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class PetController : Controller
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user