public static int CalculateSkip(BaseFilterEntityModel filterModel)
        {
            bool isValid = (filterModel.Page > 0) && (filterModel.PageSize > 0);

            if (!isValid)
            {
                return(DefaultSkip);
            }

            return((filterModel.Page - 1) * filterModel.PageSize);
        }
        public void ItWillCalculateSkip()
        {
            var filterModel = new BaseFilterEntityModel
            {
                Page     = 3,
                PageSize = 25
            };

            var skip = PaginationHelper.CalculateSkip(filterModel);

            Assert.Equal(50, skip);
        }
        public void ItWillReturnDefaultTake()
        {
            var filterModel = new BaseFilterEntityModel
            {
                Page     = -1,
                PageSize = -1
            };

            var take = PaginationHelper.CalculateTake(filterModel);

            Assert.Equal(PaginationHelper.DefaultTake, take);
        }
        public void ItWillCalculateTake()
        {
            var filterModel = new BaseFilterEntityModel
            {
                Page     = 3,
                PageSize = 25
            };

            var take = PaginationHelper.CalculateTake(filterModel);

            Assert.Equal(25, take);
        }
        public void ItWillReturnDefaultSkip()
        {
            var filterModel = new BaseFilterEntityModel
            {
                Page     = -1,
                PageSize = -1
            };

            var skip = PaginationHelper.CalculateSkip(filterModel);

            Assert.Equal(PaginationHelper.DefaultSkip, skip);
        }
        public void ItWillCalculateTotalPages()
        {
            var filterModel = new BaseFilterEntityModel
            {
                Page     = 1,
                PageSize = 25
            };

            int totalRecordCount = 90;

            var totalPages = PaginationHelper.CalculateTotalPages(filterModel, totalRecordCount);

            Assert.Equal(4, totalPages);
        }
 public static int CalculateTotalPages(BaseFilterEntityModel filterModel, int totalRecordCount)
 {
     return((int)Math.Ceiling((decimal)totalRecordCount / (decimal)filterModel.PageSize));
 }
 public static int CalculateTake(BaseFilterEntityModel filterModel)
 {
     return((filterModel.PageSize > 0) ? filterModel.PageSize : DefaultTake);
 }