From d7ddf1940788bd8207cd776c54a65f9769a840b9 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 12:54:09 +0400 Subject: [PATCH 1/3] fix transfer controller p.3 --- .../Controllers/TransferController.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Bank/BankRestApi/Controllers/TransferController.cs b/Bank/BankRestApi/Controllers/TransferController.cs index b807a91..b0d5ed2 100644 --- a/Bank/BankRestApi/Controllers/TransferController.cs +++ b/Bank/BankRestApi/Controllers/TransferController.cs @@ -20,21 +20,7 @@ namespace BankRestApi.Controllers } [HttpGet] - public List? getFullTransferList() - { - try - { - return _logic.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка переводов"); - throw; - } - } - - [HttpGet] - public List? getTransferList(int managerId) + public List? getTransferList(int? managerId) { try { From 6358f6481b7c56be211b8cb36241a95c9ef01968 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 12:57:46 +0400 Subject: [PATCH 2/3] Revert "fix transfer controller p.3" This reverts commit d7ddf1940788bd8207cd776c54a65f9769a840b9. --- .../Controllers/TransferController.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Bank/BankRestApi/Controllers/TransferController.cs b/Bank/BankRestApi/Controllers/TransferController.cs index b0d5ed2..b807a91 100644 --- a/Bank/BankRestApi/Controllers/TransferController.cs +++ b/Bank/BankRestApi/Controllers/TransferController.cs @@ -20,7 +20,21 @@ namespace BankRestApi.Controllers } [HttpGet] - public List? getTransferList(int? managerId) + public List? getFullTransferList() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка переводов"); + throw; + } + } + + [HttpGet] + public List? getTransferList(int managerId) { try { From 3bda3fd5de19934753c8c8183259ef4000e78b6a Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Sun, 26 May 2024 13:45:50 +0400 Subject: [PATCH 3/3] finish Withdrawals (but without some things) --- .../BusinessLogic/AccountLogic.cs | 12 ++ .../BusinessLogic/WithdrawalLogic.cs | 16 ++- .../BindingModels/WithdrawalBindingModel.cs | 1 + .../BusinessLogicsContracts/IAccountLogic.cs | 1 + .../IWithdrawalLogic.cs | 1 + .../SearchModels/AccountSearchModel.cs | 1 + .../SearchModels/WithdrawalSearchModel.cs | 1 + .../StoragesContracts/IAccountStorage.cs | 3 +- .../StoragesContracts/IWithdrawalStorage.cs | 3 +- .../ViewModels/WithdrawalViewModel.cs | 2 +- .../BankDataModels/Models/IWithdrawalModel.cs | 1 + .../Implements/AccountStorage.cs | 18 ++- .../Implements/WithdrawalStorage.cs | 41 ++++-- .../Models/Withdrawal.cs | 23 ++- .../Controllers/HomeController.cs | 131 ++++++++++++++---- Bank/BankManagersClientApp/Program.cs | 4 +- .../Views/Home/WithdrawalDelete.cshtml | 7 +- .../Views/Home/WithdrawalRequest.cshtml | 18 ++- .../Views/Home/WithdrawalUpdate.cshtml | 37 ++++- .../Controllers/AccountController.cs | 21 ++- .../Controllers/RequestController.cs | 9 +- .../Controllers/WithdrawalController.cs | 25 +++- 22 files changed, 312 insertions(+), 64 deletions(-) diff --git a/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs index 0c68ce3..f397ca9 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs @@ -36,6 +36,18 @@ namespace BankBusinessLogic.BusinessLogic _logger.LogInformation("ReadList Count: {Count}", list.Count); return list; } + public List ReadAccountIdsByWithdrawal(AccountSearchModel model) + { + _logger.LogInformation("ReadAccountIdsByWithdrawal. Number: {Number}, Id: {Id}", model?.Number, model?.Id); + if (model == null) + throw new ArgumentNullException(nameof(model)); + var list = _accountStorage.GetAccountIdsByWithdrawal(model); + if (list == null) + return new(); + _logger.LogInformation("ReadListByRequestId Count: {Count}", list.Count); + return list; + + } public AccountViewModel? ReadElement(AccountSearchModel model) { diff --git a/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs index 619a1e0..b905069 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs @@ -72,9 +72,21 @@ namespace BankBusinessLogic.BusinessLogic return false; } return true; - } + } - public bool Delete(WithdrawalBindingModel model) + public bool LinkToRequest(int withdrawalId, int requestId) + { + if (withdrawalId <= 0 || requestId <= 0) + return false; + if (_withdrawalStorage.LinkToRequest(withdrawalId, requestId) == null) + { + _logger.LogWarning("link operation failed"); + return false; + } + return true; + } + + public bool Delete(WithdrawalBindingModel model) { CheckModel(model, false); if (_withdrawalStorage.Delete(model) == null) diff --git a/Bank/BankContracts/BindingModels/WithdrawalBindingModel.cs b/Bank/BankContracts/BindingModels/WithdrawalBindingModel.cs index 3c99359..919cf50 100644 --- a/Bank/BankContracts/BindingModels/WithdrawalBindingModel.cs +++ b/Bank/BankContracts/BindingModels/WithdrawalBindingModel.cs @@ -12,6 +12,7 @@ namespace BankContracts.BindingModels public int Id { get; set; } public DateTime WithdrawalTime { get; set; } = DateTime.Now; public int? RequestId { get; set; } + public int Sum { get; set; } public Dictionary WithdrawalAccounts { get; set; } = new(); } } diff --git a/Bank/BankContracts/BusinessLogicsContracts/IAccountLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IAccountLogic.cs index 514d1fb..11e5d7b 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/IAccountLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/IAccountLogic.cs @@ -12,6 +12,7 @@ namespace BankContracts.BusinessLogicsContracts public interface IAccountLogic { List? ReadList(AccountSearchModel? model); + List ReadAccountIdsByWithdrawal(AccountSearchModel model); AccountViewModel? ReadElement(AccountSearchModel model); bool Create(AccountBindingModel model); bool Update(AccountBindingModel model); diff --git a/Bank/BankContracts/BusinessLogicsContracts/IWithdrawalLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IWithdrawalLogic.cs index 77b6ac9..a283e89 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/IWithdrawalLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/IWithdrawalLogic.cs @@ -15,6 +15,7 @@ namespace BankContracts.BusinessLogicsContracts WithdrawalViewModel? ReadElement(WithdrawalSearchModel model); bool Create(WithdrawalBindingModel model); bool Update(WithdrawalBindingModel model); + bool LinkToRequest(int withdrawalId, int requestId); bool Delete(WithdrawalBindingModel model); } } diff --git a/Bank/BankContracts/SearchModels/AccountSearchModel.cs b/Bank/BankContracts/SearchModels/AccountSearchModel.cs index 4bdbaad..3d45216 100644 --- a/Bank/BankContracts/SearchModels/AccountSearchModel.cs +++ b/Bank/BankContracts/SearchModels/AccountSearchModel.cs @@ -13,6 +13,7 @@ namespace BankContracts.SearchModels public DateTime? DateTo { get; set; } public DateTime? DateFrom { get; set; } public int? ManagerId { get; set; } + public int? WithdrawalId { get; set; } public List? SelectedAccountIds { get; set; } } } diff --git a/Bank/BankContracts/SearchModels/WithdrawalSearchModel.cs b/Bank/BankContracts/SearchModels/WithdrawalSearchModel.cs index 3868d5a..8ef2834 100644 --- a/Bank/BankContracts/SearchModels/WithdrawalSearchModel.cs +++ b/Bank/BankContracts/SearchModels/WithdrawalSearchModel.cs @@ -12,5 +12,6 @@ namespace BankContracts.SearchModels public DateTime? DateTo { get; set; } public DateTime? DateFrom { get; set; } public int? RequestId { get; set; } + public int? ManagerId { get; set; } } } diff --git a/Bank/BankContracts/StoragesContracts/IAccountStorage.cs b/Bank/BankContracts/StoragesContracts/IAccountStorage.cs index 8c0fe13..5138ec1 100644 --- a/Bank/BankContracts/StoragesContracts/IAccountStorage.cs +++ b/Bank/BankContracts/StoragesContracts/IAccountStorage.cs @@ -13,7 +13,8 @@ namespace BankContracts.StoragesContracts { List GetFullList(); List GetFilteredList(AccountSearchModel model); - List GetRequestsReport(AccountSearchModel model); + List GetAccountIdsByWithdrawal(AccountSearchModel model); + List GetRequestsReport(AccountSearchModel model); List GetTransfersWithdrawalsReport(AccountSearchModel model); AccountViewModel? GetElement(AccountSearchModel model); AccountViewModel? Insert(AccountBindingModel model); diff --git a/Bank/BankContracts/StoragesContracts/IWithdrawalStorage.cs b/Bank/BankContracts/StoragesContracts/IWithdrawalStorage.cs index 515e32d..8e59dd0 100644 --- a/Bank/BankContracts/StoragesContracts/IWithdrawalStorage.cs +++ b/Bank/BankContracts/StoragesContracts/IWithdrawalStorage.cs @@ -16,6 +16,7 @@ namespace BankContracts.StoragesContracts WithdrawalViewModel? GetElement(WithdrawalSearchModel model); WithdrawalViewModel? Insert(WithdrawalBindingModel model); WithdrawalViewModel? Update(WithdrawalBindingModel model); - WithdrawalViewModel? Delete(WithdrawalBindingModel model); + WithdrawalViewModel? LinkToRequest(int withdrawalId, int requestId); + WithdrawalViewModel? Delete(WithdrawalBindingModel model); } } diff --git a/Bank/BankContracts/ViewModels/WithdrawalViewModel.cs b/Bank/BankContracts/ViewModels/WithdrawalViewModel.cs index b5e7386..d322c24 100644 --- a/Bank/BankContracts/ViewModels/WithdrawalViewModel.cs +++ b/Bank/BankContracts/ViewModels/WithdrawalViewModel.cs @@ -17,7 +17,7 @@ namespace BankContracts.ViewModels [DisplayName("Номер заявки")] public int? RequestId { get; set; } [DisplayName("Сумма")] - public int? Sum { get; set; } + public int Sum { get; set; } public Dictionary WithdrawalAccounts { get; set; } = new(); } } diff --git a/Bank/BankDataModels/Models/IWithdrawalModel.cs b/Bank/BankDataModels/Models/IWithdrawalModel.cs index 261f577..ea4f277 100644 --- a/Bank/BankDataModels/Models/IWithdrawalModel.cs +++ b/Bank/BankDataModels/Models/IWithdrawalModel.cs @@ -10,6 +10,7 @@ namespace BankDataModels.Models { DateTime WithdrawalTime { get; set; } int? RequestId { get; set; } + int Sum { get; } Dictionary WithdrawalAccounts { get; } } } diff --git a/Bank/BankDatabaseImplement/Implements/AccountStorage.cs b/Bank/BankDatabaseImplement/Implements/AccountStorage.cs index 4b29845..49e463a 100644 --- a/Bank/BankDatabaseImplement/Implements/AccountStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/AccountStorage.cs @@ -22,7 +22,8 @@ namespace BankDatabaseImplement.Implements .Include(x => x.AccountWithdrawals) .Include(x => x.SenderTransfers) .Include(x => x.RecipientTransfers) - .Select(x => x.GetViewModel).ToList(); + .Select(x => x.GetViewModel) + .ToList(); } public List GetFilteredList(AccountSearchModel model) @@ -36,13 +37,20 @@ namespace BankDatabaseImplement.Implements .Where(x => (!model.Id.HasValue || x.Id == model.Id) && (!model.ManagerId.HasValue || x.ManagerId == model.ManagerId) && - (string.IsNullOrEmpty(model.Number) || x.Number == model.Number) - ) + (string.IsNullOrEmpty(model.Number) || x.Number == model.Number)) .Select(x => x.GetViewModel) .ToList(); - } + } + public List GetAccountIdsByWithdrawal(AccountSearchModel model) + { + using var context = new BankDatabase(); + return context.AccountWithdrawals + .Where(x => !model.WithdrawalId.HasValue || x.WithdrawalId == model.WithdrawalId) + .Select(x => x.AccountId) + .ToList(); + } - public AccountViewModel? GetElement(AccountSearchModel model) + public AccountViewModel? GetElement(AccountSearchModel model) { using var context = new BankDatabase(); return context.Accounts diff --git a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs index b83222b..575684d 100644 --- a/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/WithdrawalStorage.cs @@ -21,7 +21,6 @@ namespace BankDatabaseImplement.Implements .Include(x => x.Request) .Include(x => x.Accounts) .ThenInclude(x => x.Account) - .ToList() .Select(x => x.GetViewModel) .ToList(); } @@ -38,7 +37,6 @@ namespace BankDatabaseImplement.Implements (!model.RequestId.HasValue || x.RequestId == model.RequestId) && (!model.DateFrom.HasValue || x.WithdrawalTime >= model.DateFrom) && (!model.DateTo.HasValue || x.WithdrawalTime <= model.DateTo)) - .ToList() .Select(x => x.GetViewModel) .ToList(); } @@ -73,28 +71,53 @@ namespace BankDatabaseImplement.Implements { using var context = new BankDatabase(); using var transaction = context.Database.BeginTransaction(); + Withdrawal? withdrawal; try { - var Withdrawal = context.Withdrawals.FirstOrDefault(rec => + withdrawal = context.Withdrawals.FirstOrDefault(rec => rec.Id == model.Id); - if (Withdrawal == null) + if (withdrawal == null) { return null; } - Withdrawal.Update(model); + withdrawal.Update(model); context.SaveChanges(); - Withdrawal.UpdateAccounts(context, model); + withdrawal.UpdateAccounts(context, model); transaction.Commit(); - return Withdrawal.GetViewModel; } catch { transaction.Rollback(); throw; } - } + return withdrawal.GetViewModel; + } - public WithdrawalViewModel? Delete(WithdrawalBindingModel model) + public WithdrawalViewModel? LinkToRequest(int withdrawalId, int requestId) + { + 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); + if (withdrawal == null) + return null; + var newWithdrawal = new WithdrawalBindingModel + { + Sum = withdrawal.Sum, + WithdrawalTime = withdrawal.WithdrawalTime, + WithdrawalAccounts = withdrawal.WithdrawalAccounts, + RequestId = requestId + }; + withdrawal.Update(newWithdrawal); + context.SaveChanges(); + return withdrawal.GetViewModel; + } + + public WithdrawalViewModel? Delete(WithdrawalBindingModel model) { using var context = new BankDatabase(); var element = context.Withdrawals diff --git a/Bank/BankDatabaseImplement/Models/Withdrawal.cs b/Bank/BankDatabaseImplement/Models/Withdrawal.cs index ee99a44..7639bcd 100644 --- a/Bank/BankDatabaseImplement/Models/Withdrawal.cs +++ b/Bank/BankDatabaseImplement/Models/Withdrawal.cs @@ -36,7 +36,19 @@ namespace BankDatabaseImplement.Models return _withdrawalAccounts; } } - + [NotMapped] + public int Sum + { + get + { + int sum = 0; + foreach (var account in Accounts) + { + sum += account.Sum; + } + return sum; + } + } public static Withdrawal Create(BankDatabase context, WithdrawalBindingModel model) { return new Withdrawal @@ -62,7 +74,7 @@ namespace BankDatabaseImplement.Models WithdrawalTime = WithdrawalTime, WithdrawalAccounts = WithdrawalAccounts, RequestId = RequestId, - Sum = Request?.Sum, + Sum = Sum, }; public void UpdateAccounts(BankDatabase context, WithdrawalBindingModel model) @@ -72,7 +84,12 @@ namespace BankDatabaseImplement.Models { context.AccountWithdrawals.RemoveRange(WithdrawalAccounts.Where(rec => !model.WithdrawalAccounts.ContainsKey(rec.AccountId))); context.SaveChanges(); - } + foreach (var wa in WithdrawalAccounts) + { + model.WithdrawalAccounts.Remove(wa.AccountId); + } + context.SaveChanges(); + } var Withdrawal = context.Withdrawals.First(x => x.Id == Id); foreach (var account in model.WithdrawalAccounts) { diff --git a/Bank/BankManagersClientApp/Controllers/HomeController.cs b/Bank/BankManagersClientApp/Controllers/HomeController.cs index 1449e28..e1eb649 100644 --- a/Bank/BankManagersClientApp/Controllers/HomeController.cs +++ b/Bank/BankManagersClientApp/Controllers/HomeController.cs @@ -1,5 +1,8 @@ using BankContracts.BindingModels; +using BankContracts.SearchModels; using BankContracts.ViewModels; +using BankDatabaseImplement.Models; +using BankDataModels.Models; using BankManagersClientApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; @@ -317,57 +320,135 @@ namespace BankManagersClientApp.Controllers }); Response.Redirect("Transfers"); } - #endregion + #endregion - #region//работа с выдачами - public IActionResult Withdrawals() + #region//Withdrawals + [HttpGet] + public IActionResult Withdrawals() { if (APIClient.Client == null) { return Redirect("~/Home/Enter"); } + return View(APIClient.GetRequest>($"api/withdrawal/getwithdrawallist?managerid={APIClient.Client.Id}")); + } + + [HttpGet] + public IActionResult WithdrawalCreate() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Accounts = APIClient.GetRequest>($"api/account/getaccountlist?managerid={APIClient.Client.Id}"); return View(); - } + } - public IActionResult WithdrawalCreate() + [HttpPost] + public void WithdrawalCreate(int sum, List accounts) + { + if (APIClient.Client == null) + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Dictionary accountsDictionary = new(); + foreach (int account in accounts) + { + accountsDictionary.Add(account, (new AccountBindingModel { Id = account }, 0)); + } + APIClient.PostRequest("/api/withdrawal/createwithdrawal", new WithdrawalBindingModel + { + Sum = sum, + WithdrawalAccounts = accountsDictionary, + }); + Response.Redirect("Withdrawals"); + } + + [HttpGet] + public IActionResult WithdrawalUpdate() { if (APIClient.Client == null) { return Redirect("~/Home/Enter"); - } - return View(); - } + } + ViewBag.Withdrawals = APIClient.GetRequest>($"api/withdrawal/getwithdrawallist?managerid={APIClient.Client.Id}"); + ViewBag.Accounts = APIClient.GetRequest>($"api/account/getaccountlist?managerid={APIClient.Client.Id}"); + return View(); + } - public IActionResult WithdrawalUpdate() + [HttpPost] + public void WithdrawalUpdate(int withdrawal, int sum, List accounts) + { + if (APIClient.Client == null) + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Dictionary dictionary = new(); + foreach (int account in accounts) + { + dictionary.Add(account, (new AccountBindingModel + { + Id = account, + }, 0)); + } + APIClient.PostRequest("/api/withdrawal/updatewithdrawal", new WithdrawalBindingModel + { + Id = withdrawal, + Sum = sum, + WithdrawalAccounts = dictionary, + }); + Response.Redirect("Withdrawals"); + } + + [HttpGet] + public List GetAccounts(int withdrawalId) + { + if (APIClient.Client == null) + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + return APIClient.GetRequest>($"api/account/getaccounts?withdrawalId={withdrawalId}") ?? new(); + } + + [HttpGet] + public IActionResult WithdrawalDelete() { if (APIClient.Client == null) { return Redirect("~/Home/Enter"); - } - return View(); - } + } + ViewBag.Withdrawals = APIClient.GetRequest>($"api/withdrawal/getwithdrawallist?managerid={APIClient.Client.Id}"); + return View(); + } - public IActionResult WithdrawalDelete() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - return View(); - } + [HttpPost] + public void WithdrawalDelete(int withdrawal) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/withdrawal/deletewithdrawal", new WithdrawalBindingModel + { + Id = withdrawal, + }); + Response.Redirect("Withdrawals"); + } - public IActionResult WithdrawalRequest() + [HttpGet] + public IActionResult WithdrawalRequest(int? withdrawal, int? request) { if (APIClient.Client == null) { return Redirect("~/Home/Enter"); } + ViewBag.Withdrawals = APIClient.GetRequest>($"api/withdrawal/getwithdrawallist?managerid={APIClient.Client.Id}"); + ViewBag.Requests = APIClient.GetRequest>($"api/request/getrequestlist"); + if (request != null && withdrawal != null) + { + APIClient.GetRequest($"api/withdrawal/linkwithdrawalrequest?withdrawalid={withdrawal}&requestid={request}"); + return Redirect("Withdrawals"); + } return View(); - } - #endregion + } + #endregion - #region//работа с отчётами - public IActionResult RequestsListReport() + #region//работа с отчётами + public IActionResult RequestsListReport() { if (APIClient.Client == null) { diff --git a/Bank/BankManagersClientApp/Program.cs b/Bank/BankManagersClientApp/Program.cs index 005a106..d869acc 100644 --- a/Bank/BankManagersClientApp/Program.cs +++ b/Bank/BankManagersClientApp/Program.cs @@ -6,8 +6,8 @@ namespace BankManagersClientApp { var builder = WebApplication.CreateBuilder(args); - // Add services to the container. - builder.Services.AddControllersWithViews(); + // Add services to the container. + builder.Services.AddControllersWithViews(); var app = builder.Build(); diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml index 47ccf3d..a399ecb 100644 --- a/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalDelete.cshtml @@ -8,7 +8,12 @@
Выдача:
- +
diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml index b224c0b..19cdb59 100644 --- a/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalRequest.cshtml @@ -4,19 +4,27 @@

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

-
+
Выдача:
- +
Заявка:
- +
diff --git a/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml b/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml index 68544ea..e389ed0 100644 --- a/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/WithdrawalUpdate.cshtml @@ -8,7 +8,12 @@
Выдача:
- +
@@ -31,7 +36,35 @@
- +
+ +@section Scripts +{ + +} diff --git a/Bank/BankRestApi/Controllers/AccountController.cs b/Bank/BankRestApi/Controllers/AccountController.cs index 89cbbbc..a5f8afc 100644 --- a/Bank/BankRestApi/Controllers/AccountController.cs +++ b/Bank/BankRestApi/Controllers/AccountController.cs @@ -35,9 +35,26 @@ namespace BankRestApi.Controllers _logger.LogError(ex, "Ошибка получения списка счетов"); throw; } - } + } - [HttpGet] + [HttpGet] + public List GetAccounts(int withdrawalId) + { + try + { + return _logic.ReadAccountIdsByWithdrawal(new AccountSearchModel + { + WithdrawalId = withdrawalId, + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка менеджеров"); + throw; + } + } + + [HttpGet] public AccountViewModel? GetAccount(int AccountId) { try diff --git a/Bank/BankRestApi/Controllers/RequestController.cs b/Bank/BankRestApi/Controllers/RequestController.cs index e93e0f2..1fde00b 100644 --- a/Bank/BankRestApi/Controllers/RequestController.cs +++ b/Bank/BankRestApi/Controllers/RequestController.cs @@ -19,10 +19,17 @@ namespace BankRestApi.Controllers _logic = Request; } [HttpGet] - public List? GetRequestList(int clientId) + public List? GetRequestList(int? clientId) { try { + if (clientId == null) + { + List list = _logic.ReadList(null, clientId) ?? new(); + foreach(RequestViewModel r in list) + r.CardRequests = null; + return list; + } return _logic.ReadList(null, clientId); } catch (Exception ex) diff --git a/Bank/BankRestApi/Controllers/WithdrawalController.cs b/Bank/BankRestApi/Controllers/WithdrawalController.cs index 8cab52b..52480b4 100644 --- a/Bank/BankRestApi/Controllers/WithdrawalController.cs +++ b/Bank/BankRestApi/Controllers/WithdrawalController.cs @@ -20,11 +20,14 @@ namespace BankRestApi.Controllers } [HttpGet] - public List? getWithdrawalList() + public List? getWithdrawalList(int managerId) { try { - return _logic.ReadList(null); + return _logic.ReadList(new WithdrawalSearchModel + { + ManagerId = managerId, + }); } catch (Exception ex) { @@ -76,9 +79,23 @@ namespace BankRestApi.Controllers _logger.LogError(ex, "Ошибка обновления выдачи"); throw; } - } + } - [HttpPost] + [HttpGet] + public bool LinkWithdrawalRequest(int withdrawalId, int requestId) + { + try + { + return _logic.LinkToRequest(withdrawalId, requestId); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка при связывании операции с переводом"); + throw; + } + } + + [HttpPost] public void DeleteWithdrawal(WithdrawalBindingModel model) { try