From 314c2a8a71c842611e825661860144533371b216 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 22:03:20 +0400 Subject: [PATCH 1/5] some minor fixes --- .../Implements/WithdrawalStorage.cs | 20 +++---------------- .../Models/Withdrawal.cs | 6 +++++- .../Controllers/HomeController.cs | 4 ++-- .../Views/Home/WithdrawalCreate.cshtml | 6 ------ 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs index b8525ff..3bd8ebb 100644 --- a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs @@ -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; diff --git a/Bank/BankDatabaseImplement/Models/Withdrawal.cs b/Bank/BankDatabaseImplement/Models/Withdrawal.cs index 189b0af..6afb579 100644 --- a/Bank/BankDatabaseImplement/Models/Withdrawal.cs +++ b/Bank/BankDatabaseImplement/Models/Withdrawal.cs @@ -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() diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index 3ed634c..21779bb 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -347,7 +347,7 @@ namespace BankManagersClientApp.Controllers } [HttpPost] - public void WithdrawalCreate(int sum, List accounts) + public void WithdrawalCreate(List 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"); diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml index 5757754..ae1adaa 100644 --- a/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml @@ -5,12 +5,6 @@

Создание выдачи

-
-
Сумма:
-
- -
-
Счета:
From 1ee37f618c85fec4ec3191578985d78a254a73fe Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 22:26:24 +0400 Subject: [PATCH 2/5] fix filtration of transfers and withdrawals --- .../OfficePackage/AbstractSaveToExcel.cs | 2 +- .../Implements/TransferStorage.cs | 3 +- .../Implements/WithdrawalStorage.cs | 38 +++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 81bc993..6726751 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -101,7 +101,7 @@ namespace BankBusinessLogic.OfficePackage StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var transfer in transfer.Transfers) + foreach (var transfer1 in transfer.Transfers) { InsertCellInWorksheet(new ExcelCellParameters { diff --git a/Bank/BankDatabaseImplement/Implements/TransferStorage.cs b/Bank/BankDatabaseImplement/Implements/TransferStorage.cs index fa0803f..d75250f 100644 --- a/Bank/BankDatabaseImplement/Implements/TransferStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/TransferStorage.cs @@ -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) && diff --git a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs index 3bd8ebb..5840d50 100644 --- a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs @@ -29,18 +29,32 @@ namespace BankDatabaseImplement.Implements public List 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) + .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) { From 34e4891e5fcbe6498585b032ec0262c73771dc15 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 22:37:29 +0400 Subject: [PATCH 3/5] fix word report --- .../OfficePackage/AbstractSaveToWord.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 9995a25..8a474e0 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -19,11 +19,20 @@ namespace BankBusinessLogic.OfficePackage List reports = info.Requests; foreach (ReportRequestsViewModel report in reports) { + List header = new List + { + report.AccountNumber, + "", + "", + "", + "", + }; + table.Add(header); foreach (RequestViewModel request in report.Requests) { List row = new List { - report.AccountNumber, + "", request.Id.ToString(), request.Status.ToString(), request.Sum.ToString(), From a244aa66179c91f47b9e156356089c590039a6c6 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 22:38:03 +0400 Subject: [PATCH 4/5] fix withdrawal filtration --- Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs index 5840d50..3142032 100644 --- a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs @@ -44,9 +44,10 @@ namespace BankDatabaseImplement.Implements 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() + .Distinct() .Where(x => (!model.Id.HasValue || x.Id == model.Id) && (!model.RequestId.HasValue || x.RequestId == model.RequestId) && From 42c493b475d4a5d5ddf184076890fecd77c7847b Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 22:43:43 +0400 Subject: [PATCH 5/5] fix footer --- Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml b/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml index 0ba610d..efc043c 100644 --- a/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml +++ b/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml @@ -60,7 +60,7 @@
- © 2024 - BankManagersClientApp - Privacy + © 2024 - Банк - Privacy