From 85bef73abac407f83964211e681e673506d2232f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 17 Mar 2023 21:43:59 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=BF=D0=B0=D0=B3=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0=20=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B7=20=D0=B5=D0=B3=D0=BE=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectioneryClientApp/APIClient.cs | 1 + .../Controllers/HomeController.cs | 22 +++- .../Views/Home/Mails.cshtml | 120 +++++++++++------- .../Controllers/ClientController.cs | 9 +- 4 files changed, 104 insertions(+), 48 deletions(-) diff --git a/ConfectioneryClientApp/APIClient.cs b/ConfectioneryClientApp/APIClient.cs index e4620e6..2ca7837 100644 --- a/ConfectioneryClientApp/APIClient.cs +++ b/ConfectioneryClientApp/APIClient.cs @@ -10,6 +10,7 @@ namespace ConfectioneryClientApp private static readonly HttpClient _client = new(); public static ClientViewModel? Client { get; set; } = null; + public static int CurrentPage { get; set; } = 1; public static void Connect(IConfiguration configuration) { diff --git a/ConfectioneryClientApp/Controllers/HomeController.cs b/ConfectioneryClientApp/Controllers/HomeController.cs index c48230a..8e44e22 100644 --- a/ConfectioneryClientApp/Controllers/HomeController.cs +++ b/ConfectioneryClientApp/Controllers/HomeController.cs @@ -4,6 +4,7 @@ using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.ViewModels; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; +using ConfectioneryContracts.SearchModels; namespace ConfectioneryClientApp.Controllers { @@ -152,7 +153,26 @@ namespace ConfectioneryClientApp.Controllers { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}")); + ViewBag.CurrentPage = APIClient.CurrentPage; + return View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}&page={APIClient.CurrentPage}")); } + + [HttpGet] + public void SwitchPage(bool isNext) + { + if (isNext) + { + APIClient.CurrentPage++; + } + else + { + if (APIClient.CurrentPage == 1) + { + return; + } + APIClient.CurrentPage--; + } + Mails(); + } } } \ No newline at end of file diff --git a/ConfectioneryClientApp/Views/Home/Mails.cshtml b/ConfectioneryClientApp/Views/Home/Mails.cshtml index e881061..64df4b7 100644 --- a/ConfectioneryClientApp/Views/Home/Mails.cshtml +++ b/ConfectioneryClientApp/Views/Home/Mails.cshtml @@ -5,50 +5,82 @@ @{ ViewData["Title"] = "Mails"; } +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + } + +
+ Дата письма + + Заголовок + + Текст +
+ @Html.DisplayFor(modelItem => item.DateDelivery) + + @Html.DisplayFor(modelItem => item.Subject) + + @Html.DisplayFor(modelItem => item.Body) +
+ + } +
+ +

Заказы

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

Авторизируйтесь

- return; - } - - - - - - - - - - - @foreach (var item in Model) - { - - - - - - } - -
- Дата письма - - Заголовок - - Текст -
- @Html.DisplayFor(modelItem => item.DateDelivery) - - @Html.DisplayFor(modelItem => item.Subject) - - @Html.DisplayFor(modelItem => item.Body) -
- } -
+ \ No newline at end of file diff --git a/ConfectioneryRestApi/Controllers/ClientController.cs b/ConfectioneryRestApi/Controllers/ClientController.cs index 70ab65a..1d49bdb 100644 --- a/ConfectioneryRestApi/Controllers/ClientController.cs +++ b/ConfectioneryRestApi/Controllers/ClientController.cs @@ -14,6 +14,7 @@ namespace ConfectioneryRestApi.Controllers private readonly IClientLogic _logic; private readonly IMessageInfoLogic _mailLogic; + public int pageSize = 3; public ClientController(IClientLogic logic, IMessageInfoLogic mailLogic, ILogger logger) { @@ -70,13 +71,15 @@ namespace ConfectioneryRestApi.Controllers } [HttpGet] - public List? GetMessages(int clientId) + public List? GetMessages(int clientId, int page) { try { - return _mailLogic.ReadList(new MessageInfoSearchModel + return _mailLogic.ReadList(new() { - ClientId = clientId + ClientId = clientId, + Page = page, + PageSize = pageSize }); } catch (Exception ex)