Merge branch 'main' of http://student.git.athene.tech/shadowik/CourseWork_BankYouBankrupt
This commit is contained in:
commit
83318a5c56
@ -79,7 +79,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
//проверяем возможность операции снятия (sum может быть отрицательной)
|
||||
if (sum + account.Balance < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Операция невозможна. Недостаточно средств", nameof(account));
|
||||
return false;
|
||||
}
|
||||
|
||||
//обновляем балланс счёта
|
||||
|
@ -71,7 +71,7 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(CashWithdrawalBindingModel model)
|
||||
public bool Create(CashWithdrawalBindingModel model, bool flag)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
@ -82,12 +82,25 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics
|
||||
return false;
|
||||
}
|
||||
|
||||
_debitingStorage.Update(new DebitingBindingModel
|
||||
if (flag)
|
||||
{
|
||||
Id = model.DebitingId,
|
||||
DateClose = DateTime.Now,
|
||||
Status = StatusEnum.Закрыта
|
||||
});
|
||||
_debitingStorage.Update(new DebitingBindingModel
|
||||
{
|
||||
Id = model.DebitingId,
|
||||
DateClose = DateTime.Now,
|
||||
Status = StatusEnum.Закрыта
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_debitingStorage.Update(new DebitingBindingModel
|
||||
{
|
||||
Id = model.DebitingId,
|
||||
DateClose = DateTime.Now,
|
||||
Status = StatusEnum.Отклонено
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
ViewData["Title"] = "Вход";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@ -9,7 +9,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Логин:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="login" /
|
||||
<input type="text" name="login" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -3,7 +3,7 @@
|
||||
@model List<AccountViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
ViewData["Title"] = "Cписок счетов";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
|
@ -15,7 +15,7 @@ namespace BankYouBankruptContracts.BusinessLogicsContracts
|
||||
|
||||
CashWithdrawalViewModel? ReadElement(CashWithdrawalSearchModel model);
|
||||
|
||||
bool Create(CashWithdrawalBindingModel model);
|
||||
bool Create(CashWithdrawalBindingModel model, bool flag);
|
||||
|
||||
bool Update(CashWithdrawalBindingModel model);
|
||||
|
||||
|
@ -10,6 +10,8 @@ namespace BankYouBankruptDataModels.Enums
|
||||
{
|
||||
Открыта = 0,
|
||||
|
||||
Закрыта = 1
|
||||
Закрыта = 1,
|
||||
|
||||
Отклонено = 2
|
||||
}
|
||||
}
|
||||
|
@ -180,12 +180,13 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
_cashLogic.Create(CashWithdrawal);
|
||||
|
||||
_accountLogic.ChangeBalance(new AccountSearchModel
|
||||
bool flag =_accountLogic.ChangeBalance(new AccountSearchModel
|
||||
{
|
||||
Id = CashWithdrawal.AccountId
|
||||
}, CashWithdrawal.Sum * -1);
|
||||
|
||||
_cashLogic.Create(CashWithdrawal, flag);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -194,7 +195,7 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
//подтверждение заявки на снятие средств со счёта
|
||||
//подтверждение заявки на перевод либо пополнение балланса
|
||||
[HttpPost]
|
||||
public void CloseCrediting(MoneyTransferBindingModel moneyTransfer)
|
||||
{
|
||||
@ -202,19 +203,29 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
{
|
||||
_moneyTransferLogic.Create(moneyTransfer);
|
||||
|
||||
bool flag = true;
|
||||
|
||||
//если нет отправителя, т. е. операция на перевод денег из нала в виртуал на карту
|
||||
if (moneyTransfer.AccountSenderId.HasValue)
|
||||
{
|
||||
_accountLogic.ChangeBalance(new AccountSearchModel
|
||||
flag = _accountLogic.ChangeBalance(new AccountSearchModel
|
||||
{
|
||||
Id = moneyTransfer.AccountSenderId
|
||||
}, moneyTransfer.Sum * -1);
|
||||
}
|
||||
|
||||
_accountLogic.ChangeBalance(new AccountSearchModel
|
||||
if (flag)
|
||||
{
|
||||
Id = moneyTransfer.AccountPayeeId
|
||||
}, moneyTransfer.Sum);
|
||||
_accountLogic.ChangeBalance(new AccountSearchModel
|
||||
{
|
||||
Id = moneyTransfer.AccountPayeeId
|
||||
}, moneyTransfer.Sum);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Недостаточно средств");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user