some minor fixes
This commit is contained in:
parent
b8b4fb24e5
commit
314c2a8a71
@ -106,21 +106,10 @@ namespace BankDatabaseImplement.Implements
|
||||
if (requestId <= 0 || withdrawalId <= 0)
|
||||
return null;
|
||||
using var context = new BankDatabase();
|
||||
var withdrawal = context.Withdrawals
|
||||
.Include(x => x.Request)
|
||||
.Include(x => x.Accounts)
|
||||
.ThenInclude(x => x.Account)
|
||||
.FirstOrDefault(x => x.Id == withdrawalId);
|
||||
var withdrawal = context.Withdrawals.FirstOrDefault(x => x.Id == withdrawalId);
|
||||
if (withdrawal == null)
|
||||
return null;
|
||||
var newWithdrawal = new WithdrawalBindingModel
|
||||
{
|
||||
Sum = withdrawal.Sum,
|
||||
WithdrawalTime = withdrawal.WithdrawalTime,
|
||||
WithdrawalAccounts = withdrawal.WithdrawalAccounts,
|
||||
RequestId = requestId
|
||||
};
|
||||
withdrawal.Update(newWithdrawal);
|
||||
withdrawal.LinkToRequest(requestId);
|
||||
context.SaveChanges();
|
||||
return withdrawal.GetViewModel;
|
||||
}
|
||||
@ -153,10 +142,7 @@ namespace BankDatabaseImplement.Implements
|
||||
var keys = dictionary.Keys;
|
||||
foreach (int key in keys)
|
||||
{
|
||||
(IAccountModel, int) value = new();
|
||||
bool result = dictionary.TryGetValue(key, out value);
|
||||
if (!result)
|
||||
throw new InvalidOperationException("Value was not got");
|
||||
var value = dictionary[key];
|
||||
Account account = context.Accounts.FirstOrDefault(x => x.Id == key) ??
|
||||
throw new InvalidOperationException("Needed account was not found");
|
||||
int dif = count;
|
||||
|
@ -65,7 +65,11 @@ namespace BankDatabaseImplement.Models
|
||||
public void Update(WithdrawalBindingModel model)
|
||||
{
|
||||
WithdrawalTime = model.WithdrawalTime;
|
||||
RequestId = model.RequestId;
|
||||
}
|
||||
|
||||
public void LinkToRequest(int requestId)
|
||||
{
|
||||
RequestId = requestId;
|
||||
}
|
||||
|
||||
public WithdrawalViewModel GetViewModel => new()
|
||||
|
@ -347,7 +347,7 @@ namespace BankManagersClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void WithdrawalCreate(int sum, List<int> accounts)
|
||||
public void WithdrawalCreate(List<int> accounts)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
@ -358,7 +358,7 @@ namespace BankManagersClientApp.Controllers
|
||||
}
|
||||
APIClient.PostRequest("/api/withdrawal/createwithdrawal", new WithdrawalBindingModel
|
||||
{
|
||||
Sum = sum,
|
||||
Sum = 0,
|
||||
WithdrawalAccounts = accountsDictionary,
|
||||
});
|
||||
Response.Redirect("Withdrawals");
|
||||
|
@ -5,12 +5,6 @@
|
||||
<h2 class="display-4">Создание выдачи</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8">
|
||||
<input type="number" name="sum" id="sum" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Счета:</div>
|
||||
<div class="col-8">
|
||||
|
Loading…
Reference in New Issue
Block a user