From fa86861b4247e824234e2fec0ce810bb8fa938ad Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Thu, 2 May 2024 17:02:38 +0400 Subject: [PATCH 1/2] finish views --- .../Controllers/HomeController.cs | 75 +++++++++++++++++-- .../Views/Home/RequestsListReport.cshtml | 27 +++++++ .../Views/Home/TransferDelete.cshtml | 18 +++++ .../Views/Home/TransferUpdate.cshtml | 36 +++++++++ .../Views/Home/Transfers.cshtml | 4 +- .../TransfersWithdrawalsListReport.cshtml | 42 +++++++++++ .../Views/Home/WithdrawalCreate.cshtml | 31 ++++++++ .../Views/Home/WithdrawalDelete.cshtml | 18 +++++ .../Views/Home/WithdrawalRequest.cshtml | 27 ++----- .../Views/Home/WithdrawalUpdate.cshtml | 37 +++++++++ .../Views/Home/Withdrawals.cshtml | 5 +- .../Views/Shared/_Layout.cshtml | 23 +++++- 12 files changed, 309 insertions(+), 34 deletions(-) create mode 100644 Bank/BankManagersClientApp/Views/Home/RequestsListReport.cshtml create mode 100644 Bank/BankManagersClientApp/Views/Home/TransferDelete.cshtml create mode 100644 Bank/BankManagersClientApp/Views/Home/TransferUpdate.cshtml create mode 100644 Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml create mode 100644 Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml create mode 100644 Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml create mode 100644 Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index 54f17de..f57c08a 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -89,27 +89,90 @@ namespace BankManagersClientApp.Controllers return Redirect("~/Home/Enter"); } return View(); - } + } - public IActionResult Withdrawals() + public IActionResult TransferUpdate() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + public IActionResult TransferDelete() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + public IActionResult Withdrawals() { if (APIClient.Manager == null) { return Redirect("~/Home/Enter"); } return View(); - } + } - public IActionResult WithdrawalRequest() + public IActionResult WithdrawalCreate() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + public IActionResult WithdrawalUpdate() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + public IActionResult WithdrawalDelete() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + public IActionResult WithdrawalRequest() { if (APIClient.Manager == null) { return Redirect("~/Home/Enter"); } return View(); - } + } - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult RequestsListReport() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + public IActionResult TransfersWithdrawalsListReport() + { + if (APIClient.Manager == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); diff --git a/Bank/BankManagersClientApp/Views/Home/RequestsListReport.cshtml b/Bank/BankManagersClientApp/Views/Home/RequestsListReport.cshtml new file mode 100644 index 0000000..979252a --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/RequestsListReport.cshtml @@ -0,0 +1,27 @@ +@using BankContracts.ViewModels; + +@{ + ViewData["Title"] = "RequestsListReport"; +} + +
+

Список заяыок по счетам

+
+
+
+
Счета:
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/Bank/BankManagersClientApp/Views/Home/TransferDelete.cshtml b/Bank/BankManagersClientApp/Views/Home/TransferDelete.cshtml new file mode 100644 index 0000000..f4e6b36 --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/TransferDelete.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "TransferDelete"; +} +
+

Удаление перевода

+
+
+
+
Перевод:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/Bank/BankManagersClientApp/Views/Home/TransferUpdate.cshtml b/Bank/BankManagersClientApp/Views/Home/TransferUpdate.cshtml new file mode 100644 index 0000000..2582500 --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/TransferUpdate.cshtml @@ -0,0 +1,36 @@ +@{ + ViewData["Title"] = "TransferUpdate"; +} +
+

Обновление перевода

+
+
+
+
Перевод:
+
+ +
+
+
+
Сумма:
+
+ +
+
+
+
Отправитель:
+
+ +
+
+
+
Получатель:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/Bank/BankManagersClientApp/Views/Home/Transfers.cshtml b/Bank/BankManagersClientApp/Views/Home/Transfers.cshtml index 6a7d62e..66ec046 100644 --- a/Bank/BankManagersClientApp/Views/Home/Transfers.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/Transfers.cshtml @@ -14,7 +14,9 @@ return; }

- Сделать перевод + Создать перевод + Обновить перевод + Удалить перевод

diff --git a/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml new file mode 100644 index 0000000..42df840 --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/TransfersWithdrawalsListReport.cshtml @@ -0,0 +1,42 @@ +@{ + ViewData["Title"] = "TransfersWithdrawalsListReport"; +} +
+

Список счетов с расшифровкой по переводам и выдачам

+
+
+ @{ +
+
Начальная дата:
+
+ +
+
+
+
Конечная дата:
+
+ +
+
+
+ + + + + + + + + +
НомерДата/th> + СчётПереводВыдача
+
+
+
+
+
+
+
+
+ } + \ No newline at end of file diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml new file mode 100644 index 0000000..5757754 --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalCreate.cshtml @@ -0,0 +1,31 @@ +@{ + ViewData["Title"] = "WithdrawalCreate"; +} +
+

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

+
+
+
+
Сумма:
+
+ +
+
+
+
Счета:
+
+ +
+
+
+
+
+ +
+
+
diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml new file mode 100644 index 0000000..47ccf3d --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "WithdrawalDelete"; +} +
+

Удаление выдачи

+
+
+
+
Выдача:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml index da6dbea..b224c0b 100644 --- a/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml @@ -2,19 +2,14 @@ ViewData["Title"] = "WithdrawalRequest"; }
-

Выдача наличных

+

Привязывание выдачи к заявке

-
Клиент:
+
Выдача:
- -
-
-
-
Сумма:
-
- +
@@ -24,20 +19,8 @@ asp-items="@(new SelectList(@ViewBag.Requests, "Id", "Id"))">
- - - - - - - - - -
КартыСумма
-
- -
+
diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml new file mode 100644 index 0000000..68544ea --- /dev/null +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml @@ -0,0 +1,37 @@ +@{ + ViewData["Title"] = "WithdrawalUpdate"; +} +
+

Обновление выдачи

+
+
+
+
Выдача:
+
+ +
+
+
+
Сумма:
+
+ +
+
+
+
Счета:
+
+ +
+
+
+
+
+ +
+
+
diff --git a/Bank/BankManagersClientApp/Views/Home/Withdrawals.cshtml b/Bank/BankManagersClientApp/Views/Home/Withdrawals.cshtml index a28c193..b349147 100644 --- a/Bank/BankManagersClientApp/Views/Home/Withdrawals.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/Withdrawals.cshtml @@ -14,7 +14,10 @@ return; }

- Выполнить заявку на выдачу + Создать выдачу + Обновить выдачу + Удалить выдачу + Привязать выдачу к заявке

diff --git a/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml b/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml index a3ffbce..94f0151 100644 --- a/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml +++ b/Bank/BankManagersClientApp/Views/Shared/_Layout.cshtml @@ -19,10 +19,6 @@ From 599c4b1a4198f3fec2a3c3fc9acc36043fac3ada Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Thu, 2 May 2024 18:34:24 +0400 Subject: [PATCH 2/2] add reports in AccountStorage --- .../SearchModels/AccountSearchModel.cs | 4 +- .../ViewModels/ReportRequestsViewModel.cs | 15 ++++++ .../ReportTransfersWithdrawalsViewModel.cs | 16 ++++++ .../Implements/AccountStorage.cs | 53 +++++++++++++++++++ Bank/BankDatabaseImplement/Models/Request.cs | 5 +- 5 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 Bank/BankContracts/ViewModels/ReportRequestsViewModel.cs create mode 100644 Bank/BankContracts/ViewModels/ReportTransfersWithdrawalsViewModel.cs diff --git a/Bank/BankContracts/SearchModels/AccountSearchModel.cs b/Bank/BankContracts/SearchModels/AccountSearchModel.cs index 220bcf2..4bdbaad 100644 --- a/Bank/BankContracts/SearchModels/AccountSearchModel.cs +++ b/Bank/BankContracts/SearchModels/AccountSearchModel.cs @@ -10,7 +10,9 @@ namespace BankContracts.SearchModels { public int? Id { get; set; } public string? Number { get; set; } - public DateTime? ReleaseDate { get; set; } + public DateTime? DateTo { get; set; } + public DateTime? DateFrom { get; set; } public int? ManagerId { get; set; } + public List? SelectedAccountIds { get; set; } } } diff --git a/Bank/BankContracts/ViewModels/ReportRequestsViewModel.cs b/Bank/BankContracts/ViewModels/ReportRequestsViewModel.cs new file mode 100644 index 0000000..3913cc2 --- /dev/null +++ b/Bank/BankContracts/ViewModels/ReportRequestsViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.ViewModels +{ + public class ReportRequestsViewModel + { + public string AccountNumber { get; set; } = string.Empty; + public List Requests { get; set; } = new(); + } +} diff --git a/Bank/BankContracts/ViewModels/ReportTransfersWithdrawalsViewModel.cs b/Bank/BankContracts/ViewModels/ReportTransfersWithdrawalsViewModel.cs new file mode 100644 index 0000000..ff459b7 --- /dev/null +++ b/Bank/BankContracts/ViewModels/ReportTransfersWithdrawalsViewModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankContracts.ViewModels +{ + public class ReportTransfersWithdrawalsViewModel + { + public string AccountNumber { get; set; } = string.Empty; + public List SenderTransfers { get; set; } = new(); + public List RecipientTransfers { get; set; } = new(); + public List Withdrawals { get; set; } = new(); + } +} diff --git a/Bank/BankDatabaseImplement/Implements/AccountStorage.cs b/Bank/BankDatabaseImplement/Implements/AccountStorage.cs index 79e67f8..72e07f7 100644 --- a/Bank/BankDatabaseImplement/Implements/AccountStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/AccountStorage.cs @@ -103,5 +103,58 @@ namespace BankDatabaseImplement.Implements } return null; } + + public List GetRequestsReport(AccountSearchModel model) + { + using var context = new BankDatabase(); + return context.Accounts + .Where(a => model.SelectedAccountIds == null || model.SelectedAccountIds.Contains(a.Id)) + .Select(a => new ReportRequestsViewModel() + { + AccountNumber = a.Number, + Requests = context.Requests + .Include(x => x.Withdrawal) + .ThenInclude(x => x.Accounts) + .Where(x => x.Withdrawal != null && x.Withdrawal.Accounts + .Select(x => x.AccountId) + .ToList() + .Contains(a.Id)) + .Select (r => r.GetViewModel) + .ToList() + }) + .ToList(); + } + + public List GetTransfersWithdrawalsReport(AccountSearchModel model) + { + using var context = new BankDatabase(); + return context.Accounts + .Select(a => new ReportTransfersWithdrawalsViewModel() + { + AccountNumber = a.Number, + SenderTransfers = context.Transfers + .Where(t => t.TransferTime <= model.DateTo && + t.TransferTime >= model.DateFrom && + t.SenderAccountId == a.Id) + .Select(t => t.GetViewModel) + .ToList(), + RecipientTransfers = context.Transfers + .Where(t => t.TransferTime <= model.DateTo && + t.TransferTime >= model.DateFrom && + t.RecipientAccountId == a.Id) + .Select(t => t.GetViewModel) + .ToList(), + Withdrawals = context.Withdrawals + .Include(w => w.Accounts) + .Where(w => w.WithdrawalTime <= model.DateTo && + w.WithdrawalTime >= model.DateFrom && w.Accounts + .Select(x => x.AccountId) + .ToList() + .Contains(a.Id)) + .Select(w => w.GetViewModel) + .ToList() + }) + .ToList(); + } } } diff --git a/Bank/BankDatabaseImplement/Models/Request.cs b/Bank/BankDatabaseImplement/Models/Request.cs index 0992bca..b956c80 100644 --- a/Bank/BankDatabaseImplement/Models/Request.cs +++ b/Bank/BankDatabaseImplement/Models/Request.cs @@ -22,7 +22,10 @@ namespace BankDatabaseImplement.Models public RequestStatus Status { get; set; } [ForeignKey("RequestId")] public virtual List Cards { get; set; } = new(); - private Dictionary? _cardRequests { get; set; } = null; + + [ForeignKey("RequestId")] + public virtual Withdrawal? Withdrawal { get; set; } + private Dictionary? _cardRequests { get; set; } = null; [NotMapped] public Dictionary CardRequests {