diff --git a/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs index 95c368e..1e997cc 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs @@ -3,6 +3,7 @@ using BankContracts.BusinessLogicsContracts; using BankContracts.SearchModels; using BankContracts.StoragesContracts; using BankContracts.ViewModels; +using DocumentFormat.OpenXml.Wordprocessing; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -34,6 +35,18 @@ namespace BankBusinessLogic.BusinessLogic _logger.LogInformation("ReadList Count: {Count}", list.Count); return list; } + public List? ReadListByRequestId(CardSearchModel model) + { + _logger.LogInformation("ReadListByRequestId. Number: {Number}, Id: {Id}", model?.Number, model?.Id); + var list = _cardStorage.GetListForRequest(model); + if (list == null) + { + _logger.LogWarning("ReadListByRequestId return null list"); + return null; + } + _logger.LogInformation("ReadListByRequestId Count: {Count}", list.Count); + return list; + } public CardViewModel? ReadElement(CardSearchModel model) { _logger.LogInformation("ReadElement Number: {Number}, Id: {Id}", model?.Number, model?.Id); diff --git a/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs index b76ddd6..21af877 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs @@ -47,6 +47,19 @@ namespace BankBusinessLogic.BusinessLogic _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); return element; } + + public bool LinkOperationTransfer(int operationId, int transferId) + { + if (operationId <= 0 || transferId <= 0) + return false; + if (_operationStorage.LinkOperationTransfer(operationId, transferId)) + { + _logger.LogWarning("link operation failed"); + return false; + } + return true; + } + public bool Create(OperationBindingModel model) { CheckModel(model); diff --git a/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs index 31c95de..d07ab36 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs @@ -23,10 +23,10 @@ namespace BankBusinessLogic.BusinessLogic _requestStorage = requestStorage; } - public List? ReadList(RequestSearchModel? model) + public List? ReadList(RequestSearchModel? model, int? clientId) { _logger.LogInformation("ReadList. Id: {Id}", model?.Id); - var list = model == null ? _requestStorage.GetFullList() : _requestStorage.GetFilteredList(model); + var list = model == null ? _requestStorage.GetFullList(clientId) : _requestStorage.GetFilteredList(model); if (list == null) { _logger.LogWarning("ReadList return null list"); diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index 0be97d2..fc0554e 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -1,7 +1,9 @@ using BankClientApp.Models; using BankContracts.BindingModels; +using BankContracts.SearchModels; using BankContracts.ViewModels; using BankDatabaseImplement.Models; +using BankDataModels.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore.Metadata.Internal; using System.Diagnostics; @@ -183,6 +185,21 @@ namespace BankClientApp.Controllers return result; } + [HttpGet] + public List? GetCards(int requestId) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + var result = APIClient.GetRequest>($"api/card/getcards?requestid={requestId}"); + if (result == null) + { + return default; + } + return result; + } + [HttpGet] public IActionResult CardDelete() { @@ -335,13 +352,24 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } + ViewBag.Operations = APIClient.GetRequest>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}"); + ViewBag.Transfers = APIClient.GetRequest>($"api/transfer/gettransferlist"); return View(); } [HttpPost] public void OperationTransfer(int operation, int transfer) { - + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/operation/linkoperationtransfer", new OperationBindingModel + { + Id = operation, + TransferId = transfer, + }); + Response.Redirect("Operation"); } #endregion @@ -353,7 +381,7 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - return View(new List()); + return View(APIClient.GetRequest>($"api/request/getrequestlist?clientid={APIClient.Client.Id}")); } [HttpGet] @@ -363,10 +391,29 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Cards = new List(); + ViewBag.Cards = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); return View(); } + [HttpPost] + public void RequestCreate(int sum, List cards) + { + if (APIClient.Client == null) + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Dictionary a = new Dictionary(); + foreach(int card in cards) + { + a.Add(card, new CardSearchModel() { Id = card } as ICardModel); + } + APIClient.PostRequest("/api/request/createrequest", new RequestBindingModel + { + Sum = sum, + CardRequests = a, + Status = RequestStatus.Неизвестен + }); + Response.Redirect("Request"); + } + [HttpGet] public IActionResult RequestUpdate() { @@ -374,11 +421,30 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Requests = new List(); - ViewBag.Cards = new List(); + ViewBag.Requests = APIClient.GetRequest>($"api/request/getrequestlist?clientid={APIClient.Client.Id}"); + ViewBag.Cards = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); return View(); } + [HttpPost] + public void RequestUpdate(int sum, List cards) + { + if (APIClient.Client == null) + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Dictionary a = new Dictionary(); + foreach (int card in cards) + { + a.Add(card, new CardSearchModel() { Id = card } as ICardModel); + } + APIClient.PostRequest("/api/request/updaterequest", new RequestBindingModel + { + Sum = sum, + CardRequests = a, + Status = RequestStatus.Неизвестен + }); + Response.Redirect("Request"); + } + [HttpGet] public IActionResult RequestDelete() { @@ -386,13 +452,29 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Requests = new List(); + ViewBag.Requests = APIClient.GetRequest>($"api/request/getrequestlist?clientid={APIClient.Client.Id}"); return View(); } - #endregion + + [HttpPost] + public void RequestDelete(int request) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/request/deleterequest", new + RequestBindingModel + { + Id = request, + }); + Response.Redirect("Request"); + } + + #endregion #region//работа с отчетами - [HttpGet] + [HttpGet] public IActionResult Report() { if (APIClient.Client == null) diff --git a/Bank/BankClientApp/Views/Home/Operation.cshtml b/Bank/BankClientApp/Views/Home/Operation.cshtml index 0312f69..4275c39 100644 --- a/Bank/BankClientApp/Views/Home/Operation.cshtml +++ b/Bank/BankClientApp/Views/Home/Operation.cshtml @@ -17,6 +17,7 @@ Создать операцию Обновить операцию Удалить операцию + Привязать перевод

diff --git a/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml b/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml index f3a491a..17003c9 100644 --- a/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml +++ b/Bank/BankClientApp/Views/Home/OperationTransfer.cshtml @@ -1,6 +1,4 @@ -//todo выводить список только для выбранного клиента - -@{ +@{ ViewData["Title"] = "OperationTransfer"; }
@@ -78,7 +76,7 @@
-
+
@@ -93,10 +91,10 @@ url: "/Home/GetTransfer", data: { transferId: transfer }, success: function (result) { - $('#sum').val(result.item1.Sum); - $('#transfersender-number').val(result.item1.senderAccountNumber); - $('#transferrecipient-number').val(result.item1.recipientAccountNumber); - $('#transferdate').val(result.item1.transferTime); + $('#sum').val(result.Sum); + $('#transfersender-number').val(result.senderAccountNumber); + $('#transferrecipient-number').val(result.recipientAccountNumber); + $('#transferdate').val(result.transferTime); } }); }; @@ -109,10 +107,10 @@ url: "/Home/GetOperation", data: { operationId: operation }, success: function (result) { - $('#sum').val(result.item1.Sum); - $('#operationsender-number').val(result.item1.senderCardNumber); - $('#operationrecipient-number').val(result.item1.recipientCardNumber); - $('#operationdate').val(result.item1.transferTime); + $('#sum').val(result.Sum); + $('#operationsender-number').val(result.senderCardNumber); + $('#operationrecipient-number').val(result.recipientCardNumber); + $('#operationdate').val(result.operationTime); } }); }; diff --git a/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml b/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml index 30c29bd..500c533 100644 --- a/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml +++ b/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml @@ -41,22 +41,22 @@