Merge branch 'ManagersApp' of https://git.is.ulstu.ru/Artyom_Yashin/PIbd-23_Yashin_A_Zakharov_R_CourseWork_Bank into ManagersApp
This commit is contained in:
commit
68cd7db894
@ -66,13 +66,13 @@ namespace BankDatabaseImplement.Implements
|
||||
{
|
||||
MakeTransfer(context, model);
|
||||
context.Transfers.Add(newTransfer);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return newTransfer.GetViewModel;
|
||||
}
|
||||
@ -94,13 +94,13 @@ namespace BankDatabaseImplement.Implements
|
||||
});
|
||||
MakeTransfer(context, model);
|
||||
oldTransfer.Update(model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return oldTransfer.GetViewModel;
|
||||
}
|
||||
@ -121,13 +121,13 @@ namespace BankDatabaseImplement.Implements
|
||||
Sum = oldTransfer.Sum,
|
||||
});
|
||||
context.Transfers.Remove(oldTransfer);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return oldTransfer.GetViewModel;
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ namespace BankDatabaseImplement.Implements
|
||||
if (newWithdrawal == null)
|
||||
throw new InvalidOperationException("Error during creating new withdrawal");
|
||||
context.Withdrawals.Add(newWithdrawal);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return newWithdrawal.GetViewModel;
|
||||
}
|
||||
@ -102,16 +102,17 @@ namespace BankDatabaseImplement.Implements
|
||||
withdrawal = context.Withdrawals.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (withdrawal == null)
|
||||
throw new InvalidOperationException("Updating withdrawal was not found");
|
||||
if (withdrawal.RequestId != null)
|
||||
throw new InvalidOperationException("Update was rejected: withdrawal was done");
|
||||
withdrawal.Update(model);
|
||||
MakeWithdrawal(context, model);
|
||||
withdrawal.UpdateAccounts(context, model);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return withdrawal.GetViewModel;
|
||||
}
|
||||
@ -119,13 +120,24 @@ namespace BankDatabaseImplement.Implements
|
||||
public WithdrawalViewModel? LinkToRequest(int withdrawalId, int requestId)
|
||||
{
|
||||
if (requestId <= 0 || withdrawalId <= 0)
|
||||
return null;
|
||||
throw new InvalidOperationException("Id must be positive number");
|
||||
using var context = new BankDatabase();
|
||||
var withdrawal = context.Withdrawals.FirstOrDefault(x => x.Id == withdrawalId);
|
||||
if (withdrawal == null)
|
||||
return null;
|
||||
withdrawal.LinkToRequest(requestId);
|
||||
context.SaveChanges();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
Withdrawal? withdrawal;
|
||||
try
|
||||
{
|
||||
withdrawal = context.Withdrawals.FirstOrDefault(x => x.Id == withdrawalId);
|
||||
if (withdrawal == null)
|
||||
throw new InvalidOperationException("Withdrawal was not found");
|
||||
withdrawal.LinkToRequest(requestId);
|
||||
context.SaveChanges();
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
transaction.Commit();
|
||||
return withdrawal.GetViewModel;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ namespace BankManagersClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void WithdrawalUpdate(int withdrawal, int sum, List<int> accounts)
|
||||
public void WithdrawalUpdate(int withdrawal, List<int> accounts)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
@ -392,7 +392,7 @@ namespace BankManagersClientApp.Controllers
|
||||
APIClient.PostRequest("/api/withdrawal/updatewithdrawal", new WithdrawalBindingModel
|
||||
{
|
||||
Id = withdrawal,
|
||||
Sum = sum,
|
||||
Sum = 0,
|
||||
WithdrawalAccounts = dictionary,
|
||||
});
|
||||
Response.Redirect("Withdrawals");
|
||||
|
@ -16,12 +16,6 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<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">
|
||||
|
@ -60,7 +60,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Банк - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - Банк - <a asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user