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
0073eb92a4
@ -19,11 +19,20 @@ namespace BankBusinessLogic.OfficePackage
|
||||
List<ReportRequestsViewModel> reports = info.Requests;
|
||||
foreach (ReportRequestsViewModel report in reports)
|
||||
{
|
||||
List<string> header = new List<string>
|
||||
{
|
||||
report.AccountNumber,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
};
|
||||
table.Add(header);
|
||||
foreach (RequestViewModel request in report.Requests)
|
||||
{
|
||||
List<string> row = new List<string>
|
||||
{
|
||||
report.AccountNumber,
|
||||
"",
|
||||
request.Id.ToString(),
|
||||
request.Status.ToString(),
|
||||
request.Sum.ToString(),
|
||||
|
@ -33,8 +33,7 @@ namespace BankDatabaseImplement.Implements
|
||||
.Include(x => x.Operation)
|
||||
.Where(x =>
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.ManagerId.HasValue || (x.SenderAccount != null && x.SenderAccount.ManagerId == model.ManagerId) ||
|
||||
(x.RecipientAccount != null && x.RecipientAccount.ManagerId == model.ManagerId)) &&
|
||||
(!model.ManagerId.HasValue || (x.SenderAccount != null && x.SenderAccount.ManagerId == model.ManagerId)) &&
|
||||
(!model.SenderAccountId.HasValue || x.SenderAccountId == model.SenderAccountId) &&
|
||||
(!model.RecipientAccountId.HasValue || x.RecipientAccountId == model.RecipientAccountId) &&
|
||||
(!model.OperationId.HasValue || x.OperationId == model.OperationId) &&
|
||||
|
@ -29,18 +29,33 @@ namespace BankDatabaseImplement.Implements
|
||||
public List<WithdrawalViewModel> GetFilteredList(WithdrawalSearchModel model)
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
return context.Withdrawals
|
||||
.Include(x => x.Request)
|
||||
.Include(x => x.Accounts)
|
||||
.ThenInclude(x => x.Account)
|
||||
.Where(x =>
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.RequestId.HasValue || x.RequestId == model.RequestId) &&
|
||||
(!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
if (model.ManagerId == null)
|
||||
return context.Withdrawals
|
||||
.Include(x => x.Request)
|
||||
.Include(x => x.Accounts)
|
||||
.ThenInclude(x => x.Account)
|
||||
.Where(x =>
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.RequestId.HasValue || x.RequestId == model.RequestId) &&
|
||||
(!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return context.AccountWithdrawals
|
||||
.Include(x => x.Account)
|
||||
.Include (x => x.Withdrawal)
|
||||
.ThenInclude(x => x.Accounts)
|
||||
.Where(x => x.Account.ManagerId == model.ManagerId)
|
||||
.Select(x => x.Withdrawal)
|
||||
.Distinct()
|
||||
.Where(x =>
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.RequestId.HasValue || x.RequestId == model.RequestId) &&
|
||||
(!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) &&
|
||||
(!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public WithdrawalViewModel? GetElement(WithdrawalSearchModel model)
|
||||
{
|
||||
@ -106,21 +121,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 +157,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">
|
||||
|
@ -60,7 +60,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - BankManagersClientApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
© 2024 - Банк - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user