Ejemplo n.º 1
0
        public IHttpActionResult GetAll([FromUri] PageListRequest request)
        {
            var items  = MapToDoItems(_siteJsonDataHelper.LoadToDoItemsFromAppData());
            var result = new ListResponse <ToDoItemApiModel>();

            result.TotalCount = items.Count;
            request.PageSize  = 5;
            result.Items      = items.Skip(request.GetSkipCount()).Take(request.PageSize).ToList();
            return(Ok(result));
        }
Ejemplo n.º 2
0
        public async Task <PageListResponse> Get(PageListRequest request)
        {
            var allowedItems          = GetFilteredQueryByReqParamsAndUserAccess(request);
            var totalRequestItemCount = allowedItems.Count();

            allowedItems = allowedItems.Paginate(request.Query ?? new Pagenation());
            return(new PageListResponse()
            {
                Access = ResponseAccess.Granted,
                Pages = await allowedItems.ToViewModelListAsync(),
                Count = totalRequestItemCount
            });
        }
Ejemplo n.º 3
0
        static async Task MainAsync()
        {
            var listRequest = new PageListRequest <Product>();

            listRequest.AddFilterInClouse("ProductID", 1, 2, 3, 4, 5, 6, 7).AddFilterContains("ProductName", "h");

            var watch = new Stopwatch();

            watch.Start();


            Parallel.For(0, 1000, new ParallelOptions {
                MaxDegreeOfParallelism = 8
            }, (i) =>
            {
                dbConnection.GetPagedListAsync <Product>(listRequest).Wait();
            });



            watch.Stop();
            Console.WriteLine(watch.ElapsedMilliseconds + " Ticks: " + watch.ElapsedTicks);
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        private IQueryable <DomainClasses.Entities.Page> GetFilteredQueryByReqParamsAndUserAccess(PageListRequest request)
        {
            var pageQuery  = AccessManager.Filter(_dataSrv.Query.Where(x => x.LanguageName == request.Query.LanguageName));
            var searchText = request.Query?.SearchText;

            if (!string.IsNullOrEmpty(searchText))
            {
                pageQuery = pageQuery.Where(x => x.Title.Contains(searchText));
            }

            pageQuery = pageQuery.OrderByDescending(x => x.Id);
            return(pageQuery);
        }