From de87a95cf21fdff417b46d28b54338809c653b2c Mon Sep 17 00:00:00 2001 From: shadowik Date: Wed, 17 May 2023 16:46:18 +0400 Subject: [PATCH] View Model for Creditings --- .../Controllers/HomeController.cs | 7 ++++++- .../Views/Home/CreateCrediting.cshtml | 2 +- .../ViewModels/ClientCardViewModel.cs | 17 +++++++++++++++++ .../Controllers/CardController.cs | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index bea630d..f4fae54 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -210,7 +210,12 @@ namespace BankYouBankruptClientApp.Controllers return Redirect("~/Home/Enter"); } - ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}"); + + ViewBag.Cards = APIClient.GetRequest>($"api/Card/GetAllCards").Select(x => new ClientCardViewModel + { + Id = x.Id, + FullName = x.ClientSurname + " " +x.Number.ToString() + }).ToList(); return View(); } diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCrediting.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCrediting.cshtml index d67cbfd..cbb5189 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCrediting.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCrediting.cshtml @@ -9,7 +9,7 @@
Номер счета:
- +
diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs new file mode 100644 index 0000000..0ef220c --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/ClientCardViewModel.cs @@ -0,0 +1,17 @@ +using BankYouBankruptDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankYouBankruptContracts.ViewModels +{ + public class ClientCardViewModel + { + public int Id { get; set; } + + public string FullName { get; set; } = string.Empty; + } +} diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs index 92e6dac..d8fc4a8 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/CardController.cs @@ -31,6 +31,22 @@ namespace BankYouBankruptRestApi.Controllers _accountLogic = accountLogic; } + [HttpGet] + public List? GetAllCards() + { + try + { + return _cardLogic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения карт"); + throw; + } + + } + + [HttpGet] public List? GetUsersCardsList(int id) {