Контроллер счёта.
This commit is contained in:
parent
9670a68493
commit
7fb925523d
@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class CashierLogic : ICashierLogic
|
||||
public class CashierLogic : IAccountLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
|
@ -0,0 +1,91 @@
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.BusinessLogicsContracts;
|
||||
using BankYouBankruptContracts.SearchModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankYouBankruptRestApi.Controllers
|
||||
{
|
||||
//указание у контроллера, что Route будет строиться не только по наванию контроллера, но и по названию метода (так как у нас два Post-метода)
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class AccountController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IAccountLogic _accountLogic;
|
||||
|
||||
public AccountController(IAccountLogic accountLogic, ILogger<AccountController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_accountLogic = accountLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public AccountViewModel? Login(string accountNumber, string passwordAccount)
|
||||
{
|
||||
try
|
||||
{
|
||||
//попытка найти запись по переданным номеру и паролю счёта
|
||||
return _accountLogic.ReadElement(new AccountSearchModel
|
||||
{
|
||||
AccountNumber = accountNumber,
|
||||
PasswordAccount = passwordAccount
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Register(AccountBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
//создание счёта
|
||||
_accountLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка регистрации");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateData(AccountBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
//изменение счёта
|
||||
_accountLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления данных");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<AccountViewModel>? SearchAllAccounts(int cashierId)
|
||||
{
|
||||
try
|
||||
{
|
||||
//попытка найти запись по переданным номеру и паролю счёта
|
||||
return _accountLogic.ReadList(new AccountSearchModel
|
||||
{
|
||||
CashierId = cashierId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly ICashierLogic _cashierLogic;
|
||||
private readonly IAccountLogic _cashierLogic;
|
||||
|
||||
public CashierController(ICashierLogic cashierLogic, ILogger<CashierController> logger)
|
||||
public CashierController(IAccountLogic cashierLogic, ILogger<AccountController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_cashierLogic = cashierLogic;
|
||||
|
@ -21,7 +21,7 @@ builder.Services.AddTransient<IDebitingStorage, DebitingStorage>();
|
||||
builder.Services.AddTransient<ICashWithdrawalStorage, CashWithdrawalStorage>();
|
||||
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<ICashierLogic, CashierLogic>();
|
||||
builder.Services.AddTransient<IAccountLogic, CashierLogic>();
|
||||
builder.Services.AddTransient<IAccountLogic, AccountLogic>();
|
||||
builder.Services.AddTransient<ICardLogic, CardLogic>();
|
||||
builder.Services.AddTransient<ICreditingLogic, CreditingLogic>();
|
||||
|
Loading…
Reference in New Issue
Block a user