.
This commit is contained in:
parent
d707d5300e
commit
9670a68493
@ -0,0 +1,54 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net;
|
||||
|
||||
namespace BankYouBankruptRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class CardController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ICardLogic _cardLogic;
|
||||
|
||||
public CardController(ICardLogic cardLogic, ILogger<ClientController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_cardLogic = cardLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<CardViewModel>? GetUsersCardsList(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _cardLogic.ReadList(new CardSearchModel { Id = id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения карт");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateCard(CardBindingModel model) {
|
||||
try
|
||||
{
|
||||
_cardLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания карты");
|
||||
Response.StatusCode = (int)HttpStatusCode.NotAcceptable;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user