< Summary

Class:WinSolutions.Sveta.Server.Domain.PaginatedList`1
Assembly:WinSolutions.Sveta.Server
File(s):/opt/dev/sveta_api_build/WinSolutions.Sveta.Server/Domain/PaginatedList.cs
Covered lines:0
Uncovered lines:19
Coverable lines:19
Total lines:41
Line coverage:0% (0 of 19)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodLine coverage Branch coverage
get_CurrentPage()0%100%
get_TotalPage()0%100%
.ctor(...)0%100%
get_HasPreviousPage()0%100%
get_HasNextPage()0%100%
CreateAsync()0%0%

File(s)

/opt/dev/sveta_api_build/WinSolutions.Sveta.Server/Domain/PaginatedList.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using System;
 3using System.Collections.Generic;
 4using System.Linq;
 5using System.Text;
 6using System.Threading.Tasks;
 7
 8namespace WinSolutions.Sveta.Server.Domain
 9{
 10    public class PaginatedList<T>: List<T>
 11    {
 012        public int CurrentPage { get; private set; }
 013        public int TotalPage { get; private set; }
 014        public PaginatedList(List<T> items, int count, int currentPage, int limit)
 015        {
 016            CurrentPage = currentPage;
 017            TotalPage = (int)Math.Ceiling(count / (double)limit);
 018            this.AddRange(items);
 019        }
 20        public bool HasPreviousPage
 21        {
 22            get
 023            {
 024                return (CurrentPage > 1);
 025            }
 26        }
 27        public bool HasNextPage
 28        {
 29            get
 030            {
 031                return (CurrentPage < TotalPage);
 032            }
 33        }
 34        public static async Task<PaginatedList<T>> CreateAsync(IQueryable<T> source, int currentPage, int limit)
 035        {
 036            var count = await source.CountAsync();
 037            var items = await source.Skip(currentPage * limit).Take(limit).ToListAsync();
 038            return new PaginatedList<T>(items, count, currentPage, limit);
 039        }
 40    }
 41}