From 1c1f1926daac63e43a62eb722dc034717fa589a7 Mon Sep 17 00:00:00 2001 From: shadowik Date: Wed, 17 May 2023 01:00:04 +0400 Subject: [PATCH 1/2] clientapp test --- .../Views/Shared/_Layout.cshtml | 2 +- .../Controllers/HomeController.cs | 53 ++++++++++++++++--- .../BankYouBankruptClientApp/Program.cs | 2 +- .../Views/Home/CreateCard.cshtml | 39 ++++++++++++++ .../Views/Home/Enter.cshtml | 8 ++- .../Views/Home/Index.cshtml | 45 ++++++++++++++-- .../Views/Home/Profile.cshtml | 23 ++++++++ .../Views/Home/Register.cshtml | 6 +++ .../Views/Shared/_Layout.cshtml | 25 ++------- 9 files changed, 167 insertions(+), 36 deletions(-) create mode 100644 BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCard.cshtml create mode 100644 BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Profile.cshtml diff --git a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Shared/_Layout.cshtml b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Shared/_Layout.cshtml index a32b0aa..d3161b1 100644 --- a/BankYouBankrupt/BankYouBankruptCashierApp/Views/Shared/_Layout.cshtml +++ b/BankYouBankrupt/BankYouBankruptCashierApp/Views/Shared/_Layout.cshtml @@ -50,7 +50,7 @@ diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index 6c15b05..bf60b49 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -18,7 +18,6 @@ namespace BankYouBankruptClientApp.Controllers _logger = logger; } - //вытаскивает через API клиента Get-запросом список его собственных заказов [HttpGet] public IActionResult Index() { @@ -27,6 +26,18 @@ namespace BankYouBankruptClientApp.Controllers return Redirect("~/Home/Enter"); } + return View(APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}")); + } + + + [HttpGet] + public IActionResult Profile() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.GetRequest($"api/Client/GetClient?clientId={APIClient.Client.Id}")); } @@ -41,14 +52,13 @@ namespace BankYouBankruptClientApp.Controllers }); } - //просто открытие вьюхи [HttpGet] public IActionResult Enter() { return View(); } - //отсылаем указанные данные на проверку + [HttpPost] public void Enter(string login, string password) { @@ -64,17 +74,17 @@ namespace BankYouBankruptClientApp.Controllers throw new Exception("Неверный логин/пароль"); } - Response.Redirect("Index"); + Response.Redirect("Profile"); } - //просто открытие вьюхи + [HttpGet] public IActionResult Register() { return View(); } - //Post-запрос по созданию нового пользователя + [HttpPost] public void Register(string login, string password, string name, string surname, string patronymic, string telephone) { @@ -94,10 +104,37 @@ namespace BankYouBankruptClientApp.Controllers Telephone = telephone }); - //переход на вкладку "Enter", чтобы пользователь сразу смог зайти Response.Redirect("Enter"); return; } - } + + [HttpGet] + public IActionResult CreateCard() { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + + return View(); + } + + [HttpPost] + public IActionResult CreateCard(string account, string number, string cvc, string period) { + if (APIClient.Client == null) + { + throw new Exception("Не авторизованы"); + } + + APIClient.PostRequest("api/Card/CreateCard", new CardBindingModel { + ClientID = APIClient.Client.Id, + AccountId = int.Parse(account), + Number = number, + CVC = cvc, + Period = DateTime.Parse(period) + }); + + return Redirect("~/Home/Index"); + } + } } \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Program.cs b/BankYouBankrupt/BankYouBankruptClientApp/Program.cs index d6dc1cf..811e8e8 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Program.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Program.cs @@ -26,6 +26,6 @@ app.UseAuthorization(); app.MapControllerRoute( name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); + pattern: "{controller=Home}/{action=Profile}/{id?}"); app.Run(); diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCard.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCard.cshtml new file mode 100644 index 0000000..378baf6 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreateCard.cshtml @@ -0,0 +1,39 @@ +@{ + ViewData["Title"] = "Register"; +} + +
+

Создание карты

+
+
+
+
Номер счета:
+
+ +
+
+
+
Номер карты:
+
+ +
+
+
+
CVC:
+
+ +
+
+
+
Срок действия:
+
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Enter.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Enter.cshtml index 8e277d4..067ef37 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Enter.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Enter.cshtml @@ -9,7 +9,7 @@
Логин:
-
@@ -24,4 +24,10 @@
+ \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Index.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Index.cshtml index 7ab417c..39595ce 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Index.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Index.cshtml @@ -1,13 +1,13 @@ @using BankYouBankruptContracts.ViewModels -@model ClientViewModel +@model List @{ ViewData["Title"] = "Home Page"; }
-

Страница пользователя

+

Карты

@@ -17,10 +17,45 @@

Сначала авторизируйтесь

return; } - -

Здравствуйтe, @Model.Name @Model.Patronymic

- Открыть счёт + Создать карту

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Номер счёта + + CVC + + Фамилия владельца + + Срок действия +
+ @Html.DisplayFor(modelItem => item.Number) + + @Html.DisplayFor(modelItem => item.CVC) + + @Html.DisplayFor(modelItem => item.ClientSurname) + + @Html.DisplayFor(modelItem => item.Period) +
}
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Profile.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Profile.cshtml new file mode 100644 index 0000000..bca92be --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Profile.cshtml @@ -0,0 +1,23 @@ +@using BankYouBankruptContracts.ViewModels + +@model ClientViewModel + +@{ + ViewData["Title"] = "Home Page"; +} + +
+

Страница пользователя

+
+ +
+ @{ + if (Model == null) + { +

Сначала авторизируйтесь

+ return; + } + +

Здравствуйтe, @Model.Name @Model.Patronymic

+ } +
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Register.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Register.cshtml index 35db21b..e2376bf 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Register.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Register.cshtml @@ -48,4 +48,10 @@ + \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml index dda2b99..b086fb3 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml @@ -1,4 +1,5 @@ - + + @@ -13,29 +14,13 @@