From 3a0491b54dbd2bd66d3f009e7db501b1a58336ed Mon Sep 17 00:00:00 2001 From: Artyom_Yashin Date: Sun, 26 May 2024 12:10:15 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A4=D0=BE=D1=80=D0=BC=D0=B0=20=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B7?= =?UTF-8?q?=D0=B0=D1=8F=D0=B2=D0=BE=D0=BA=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bank/BankClientApp/APIClient.cs | 5 ++++- .../Controllers/HomeController.cs | 19 ++++++++++++++++++- .../Views/Home/RequestUpdate.cshtml | 13 ++++++++----- .../Implements/RequestStorage.cs | 2 +- .../Controllers/RequestController.cs | 4 +++- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Bank/BankClientApp/APIClient.cs b/Bank/BankClientApp/APIClient.cs index 86b03de..3b0fcde 100644 --- a/Bank/BankClientApp/APIClient.cs +++ b/Bank/BankClientApp/APIClient.cs @@ -23,7 +23,10 @@ namespace BankClientApp var result = response.Result.Content.ReadAsStringAsync().Result; if (response.Result.IsSuccessStatusCode) { - return JsonConvert.DeserializeObject(result); + return JsonConvert.DeserializeObject(result, new JsonSerializerSettings { + TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + }); } else { diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index e6fb211..9872473 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -427,7 +427,7 @@ namespace BankClientApp.Controllers } [HttpPost] - public void RequestUpdate(int sum, List cards) + public void RequestUpdate(int request, int sum, List cards) { if (APIClient.Client == null) throw new Exception("Вы как суда попали? Суда вход только авторизованным"); @@ -438,6 +438,7 @@ namespace BankClientApp.Controllers } APIClient.PostRequest("/api/request/updaterequest", new RequestBindingModel { + Id = request, Sum = sum, CardRequests = a, Status = RequestStatus.Неизвестен @@ -471,6 +472,22 @@ namespace BankClientApp.Controllers Response.Redirect("Request"); } + [HttpGet] + public RequestViewModel? GetRequest(int requestId) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + var result = APIClient.GetRequest($"api/request/getrequest?requestid={requestId}"); + result.CardRequests = null; + if (result == null) + { + return default; + } + return result; + } + #endregion #region//работа с отчетами diff --git a/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml b/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml index 500c533..40ed86a 100644 --- a/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml +++ b/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml @@ -40,23 +40,26 @@ { diff --git a/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml b/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml index 40ed86a..680da57 100644 --- a/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml +++ b/Bank/BankClientApp/Views/Home/RequestUpdate.cshtml @@ -49,7 +49,7 @@ data: { requestId: request }, success: function (result) { $.map(result, function (n) { - $(`option[value=${n}]`).attr("selected", "selected") + $(`#cards option[value=${n}]`).attr("selected", "selected") }); } });