diff --git a/Shipyard/ShipyardClientApp/Controllers/HomeController.cs b/Shipyard/ShipyardClientApp/Controllers/HomeController.cs index 1896225..180da85 100644 --- a/Shipyard/ShipyardClientApp/Controllers/HomeController.cs +++ b/Shipyard/ShipyardClientApp/Controllers/HomeController.cs @@ -144,13 +144,16 @@ namespace ShipyardClientApp.Controllers return count * (prod?.Price ?? 1); } [HttpGet] - public IActionResult Mails() + public IActionResult Mails(int page=0) { if (APIClient.Client == null) { return Redirect("~/Home/Enter"); } - return View(APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}")); + var messages = APIClient.GetRequest>($"api/client/getmessages?clientId={APIClient.Client.Id}&page={page}"); + ViewBag.IsLast = messages!.Count() == 0 ? true : false; + ViewBag.Page = page; + return View(messages); } } } \ No newline at end of file diff --git a/Shipyard/ShipyardClientApp/Views/Home/Mails.cshtml b/Shipyard/ShipyardClientApp/Views/Home/Mails.cshtml index 77d719f..c8b6771 100644 --- a/Shipyard/ShipyardClientApp/Views/Home/Mails.cshtml +++ b/Shipyard/ShipyardClientApp/Views/Home/Mails.cshtml @@ -50,4 +50,18 @@ } + @if (ViewBag.Page > 0) + { + + « Предыдущая + + } + @if (!ViewBag.IsLast) + { + + Следующая » + + } \ No newline at end of file diff --git a/Shipyard/ShipyardRestApi/Controllers/ClientController.cs b/Shipyard/ShipyardRestApi/Controllers/ClientController.cs index 3686a77..1e31ffc 100644 --- a/Shipyard/ShipyardRestApi/Controllers/ClientController.cs +++ b/Shipyard/ShipyardRestApi/Controllers/ClientController.cs @@ -69,13 +69,15 @@ namespace ShipyardRestApi.Controllers } } [HttpGet] - public List? GetMessages(int clientId) + public List? GetMessages(int clientId,int page,int countPerPage = 5) { try { return _mailLogic.ReadList(new MessageInfoSearchModel { - ClientId = clientId + ClientId = clientId, + Page = page, + PageCount = countPerPage }); } catch (Exception ex)