Artyom_Yashin 2024-04-29 13:59:15 +04:00
commit 568700a1ae
5 changed files with 381 additions and 1 deletions

View File

@ -0,0 +1,96 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.AspNetCore.Mvc;
namespace BankRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class AccountController : Controller
{
private readonly ILogger _logger;
private readonly IAccountLogic _logic;
public AccountController(ILogger logger, IAccountLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<AccountViewModel>? GetAccountList()
{
try
{
return _logic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка счетов");
throw;
}
}
[HttpGet]
public AccountViewModel? GetAccount(int AccountId)
{
try
{
return _logic.ReadElement(new AccountSearchModel
{
Id = AccountId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения счета по Id={Id}", AccountId);
throw;
}
}
[HttpPost]
public void CreateAccount(AccountBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания счета");
throw;
}
}
[HttpPut]
public void UpdateAccount(AccountBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления счета");
throw;
}
}
[HttpDelete]
public void DeleteAccount(AccountBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления счета");
throw;
}
}
}
}

View File

@ -49,7 +49,8 @@ namespace BankRestApi.Controllers
{
Id = ClientId
});
}catch (Exception ex)
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения клиента по Id={Id}", ClientId);
throw;

View File

@ -0,0 +1,97 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using BankDatabaseImplement.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace BankRestApi.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ManagerController : Controller
{
private readonly ILogger _logger;
private readonly IManagerLogic _logic;
public ManagerController(ILogger logger, IManagerLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<ManagerViewModel>? GetManagerList()
{
try
{
return _logic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка менеджеров");
throw;
}
}
[HttpGet]
public ManagerViewModel? GetManager(int ManagerId)
{
try
{
return _logic.ReadElement(new ManagerSearchModel
{
Id = ManagerId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения менеджера по Id={Id}", ManagerId);
throw;
}
}
[HttpPost]
public void CreateManager(ManagerBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания менеджера");
throw;
}
}
[HttpPut]
public void UpdateManager(ManagerBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления менеджера");
throw;
}
}
[HttpDelete]
public void DeleteManager(ManagerBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления менеджера");
throw;
}
}
}
}

View File

@ -0,0 +1,93 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BankRestApi.Controllers
{
public class TransferController : Controller
{
private readonly ILogger _logger;
private readonly ITransferLogic _logic;
public TransferController(ILogger logger, ITransferLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<TransferViewModel>? getTransferList()
{
try
{
return _logic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка переводов");
throw;
}
}
[HttpGet]
public TransferViewModel? GetTransfer(int TransferId)
{
try
{
return _logic.ReadElement(new TransferSearchModel
{
Id = TransferId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения перевода по Id={Id}", TransferId);
throw;
}
}
[HttpPost]
public void CreateTransfer(TransferBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания перевода");
throw;
}
}
[HttpPut]
public void UpdateTransfer(TransferBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления перевода");
throw;
}
}
[HttpDelete]
public void DeleteTransfer(TransferBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления перевода");
throw;
}
}
}
}

View File

@ -0,0 +1,93 @@
using BankContracts.BindingModels;
using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels;
using BankContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BankRestApi.Controllers
{
public class WithdrawalController : Controller
{
private readonly ILogger _logger;
private readonly IWithdrawalLogic _logic;
public WithdrawalController(ILogger logger, IWithdrawalLogic logic)
{
_logger = logger;
_logic = logic;
}
[HttpGet]
public List<WithdrawalViewModel>? getWithdrawalList()
{
try
{
return _logic.ReadList(null);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка выдач");
throw;
}
}
[HttpGet]
public WithdrawalViewModel? GetWithdrawal(int WithdrawalId)
{
try
{
return _logic.ReadElement(new WithdrawalSearchModel
{
Id = WithdrawalId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения выдачи по Id={Id}", WithdrawalId);
throw;
}
}
[HttpPost]
public void CreateWithdrawal(WithdrawalBindingModel model)
{
try
{
_logic.Create(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания выдачи");
throw;
}
}
[HttpPut]
public void UpdateWithdrawal(WithdrawalBindingModel model)
{
try
{
_logic.Update(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка обновления выдачи");
throw;
}
}
[HttpDelete]
public void DeleteWithdrawal(WithdrawalBindingModel model)
{
try
{
_logic.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления выдачи");
throw;
}
}
}
}