Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 004c4a4e

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Removed paging from GET /documents

Zobrazit rozdíly:

Backend/Core/Services/DocumentService/DocumentServiceEF.cs
113 113
            databaseContext.SaveChanges();
114 114
        }
115 115

  
116
        public DocumentListResponse GetDocuments(int pageIndex, int pageSize)
116
        public DocumentListResponse GetDocuments()
117 117
        {
118
            var firstIndex = pageIndex * pageSize;
119
            var documents = databaseContext.Documents.Select(d => d).ToList();
120
            var totalCount = documents.Count;
121
            var pageCount = totalCount / pageSize;
122
            if (pageCount == 0 && totalCount > 0)
123
            {
124
                pageCount = 1;
125
            }
126

  
127
            if (firstIndex > documents.Count - 1)
128
            {
129
                throw new Exception("Page index or page size too large");
130
            }
131

  
132
            if (firstIndex + pageSize > documents.Count - 1)
133
            {
134
                pageSize = documents.Count - firstIndex;
135
            }
136

  
118
            var documents = databaseContext.Documents.ToList();
137 119
            List<DocumentListInfo> documentInfos = new List<DocumentListInfo>();
138
            foreach (var document in documents.GetRange(firstIndex, pageSize))
120
            foreach (var document in documents)
139 121
            {
140 122
                var annotatingUsers = databaseContext.Annotations
141 123
                    .Where(a => !(a is FinalAnnotation))
......
190 172

  
191 173
            return new DocumentListResponse()
192 174
            {
193
                PageCount = pageCount,
194
                PageIndex = pageIndex,
195
                TotalCount = totalCount,
196 175
                Documents = documentInfos.OrderBy(di => di.Name).ToList()
197 176
            };
198 177
        }

Také k dispozici: Unified diff