commit 42c654f6b251416bf1cf4460f19f69a586940155
Author: Vojtěch Bartička <aitakaitov@gmail.com>
Date:   Sat Apr 16 20:30:35 2022 +0200

    Same fix in DocumentController - moved to QueryParams

diff --git a/Backend/Backend/Controllers/DocumentController.cs b/Backend/Backend/Controllers/DocumentController.cs
index 9596176..ba846bc 100644
--- a/Backend/Backend/Controllers/DocumentController.cs
+++ b/Backend/Backend/Controllers/DocumentController.cs
@@ -28,7 +28,7 @@ public class DocumentController : Common.CommonControllerBase
     [Authorize(Models.Enums.ERole.ADMINISTRATOR)]
     [ProducesResponseType((int)HttpStatusCode.OK)]
     [ProducesResponseType((int)HttpStatusCode.Forbidden)]
-    public ActionResult<DocumentListResponse> GetDocuments([FromServices] ClientInfo clientInfo, [FromBody] DocumentListRequest documentListRequest)
+    public ActionResult<DocumentListResponse> GetDocuments([FromServices] ClientInfo clientInfo, [FromQuery] int pageIndex, [FromQuery] int pageSize)
     {
         if (clientInfo.LoggedUser == null)
         {
@@ -36,7 +36,7 @@ public class DocumentController : Common.CommonControllerBase
             return Problem();
         }
 
-        return documentService.GetDocuments(documentListRequest);
+        return documentService.GetDocuments(pageIndex, pageSize);
     }
 
     [HttpPost("/documents")]
diff --git a/Backend/Core/Services/DocumentService/DocumentServiceEF.cs b/Backend/Core/Services/DocumentService/DocumentServiceEF.cs
index 3299579..7c38428 100644
--- a/Backend/Core/Services/DocumentService/DocumentServiceEF.cs
+++ b/Backend/Core/Services/DocumentService/DocumentServiceEF.cs
@@ -110,12 +110,12 @@ namespace Core.Services.DocumentService
             databaseContext.SaveChanges();                  // Maybe do this after all the documents are added
         }
 
-        public DocumentListResponse GetDocuments(DocumentListRequest request)
+        public DocumentListResponse GetDocuments(int pageIndex, int pageSize)
         {
-            var firstIndex = request.PageIndex * request.PageSize;
+            var firstIndex = pageIndex * pageSize;
             var documents = databaseContext.Documents.Select(d => d).ToList();
             var totalCount = documents.Count;
-            var pageCount = totalCount / request.PageSize;
+            var pageCount = totalCount / pageSize;
             if (pageCount == 0 && totalCount > 0)
             {
                 pageCount = 1;
@@ -126,13 +126,13 @@ namespace Core.Services.DocumentService
                 throw new Exception("Page index or page size too large");
             }
 
-            if (firstIndex + request.PageSize > documents.Count - 1)
+            if (firstIndex + pageSize > documents.Count - 1)
             {
-                request.PageSize = documents.Count - firstIndex;
+                pageSize = documents.Count - firstIndex;
             }
 
             List<DocumentListInfo> documentInfos = new List<DocumentListInfo>();
-            foreach (var document in documents.GetRange(firstIndex, request.PageSize))
+            foreach (var document in documents.GetRange(firstIndex, pageSize))
             {
                 var annotatingUsers = databaseContext.Annotations.Where(a => a.Document == document).Select(a => a.User).ToList();
                 List<UserInfo> annotatingUsersDto = annotatingUsers.Select(a => mapper.Map<UserInfo>(a)).ToList();
@@ -145,7 +145,7 @@ namespace Core.Services.DocumentService
             return new DocumentListResponse()
             {
                 PageCount = pageCount,
-                PageIndex = request.PageIndex,
+                PageIndex = pageIndex,
                 TotalCount = totalCount,
                 Documents = documentInfos
             };
diff --git a/Backend/Core/Services/DocumentService/IDocumentService.cs b/Backend/Core/Services/DocumentService/IDocumentService.cs
index 8a21fb7..ed2943b 100644
--- a/Backend/Core/Services/DocumentService/IDocumentService.cs
+++ b/Backend/Core/Services/DocumentService/IDocumentService.cs
@@ -13,6 +13,6 @@ namespace Core.Services.DocumentService
     {
         public void AddDocuments(DocumentAddRequest request, Guid userId);
 
-        public DocumentListResponse GetDocuments(DocumentListRequest request);
+        public DocumentListResponse GetDocuments(int pageIdnex, int pageSize);
     }
 }
