Beispiel #1
0
        internal static ProductPageModel GetPageModel(Product current)
        {
            ProductPageModel model = new ProductPageModel();
            var temp = new List <Product>
            {
                current
            };

            model._entries = temp.AsQueryable();
            return(model);
        }
Beispiel #2
0
        internal static ProductPageModel GetPageModel(int currentPageNum, AppDatabaseContext ctx, Product.SortType sortType, string searchName, int minPrice, int maxPrice)
        {
            var pageCount = ctx.Products.Count() / MAX_PAGE_LENGTH;

            if (ctx.Products.Count() % MAX_PAGE_LENGTH != 0)
            {
                pageCount++;
            }
            if (pageCount <= currentPageNum)
            {
                return(EMPTY_MODEL);
            }
            ProductPageModel model = new ProductPageModel
            {
                _sortType       = sortType.ToString(),
                _pageCount      = pageCount,
                _currentPageNum = currentPageNum,
                _entries        = ctx.GetSortedQuery(currentPageNum * MAX_PAGE_LENGTH, MAX_PAGE_LENGTH, sortType, searchName, minPrice, maxPrice)
            };

            return(model);
        }