Ejemplo n.º 1
0
        public async Task <IActionResult> UnapprovedSongs(int page = 1)
        {
            GetUnapprovedSongs getSongsQuery = new GetUnapprovedSongs()
            {
                PageInfo = new PageInfo(page, DefaultPageSize)
            };

            IEnumerable <Song> unapprovedSongs = await this.getUnapprovedSongs.ExecuteAsync(getSongsQuery);

            GetSongsCount getSongsCountQuery = new GetSongsCount()
            {
                Approved   = false,
                SearchInfo = new SearchInfo(null)
            };

            int songsCount = await this.getSongsCount.ExecuteAsync(getSongsCountQuery);

            IEnumerable <SongListingViewModel> songsModel =
                Mapper.Map <IEnumerable <SongListingViewModel> >(unapprovedSongs);

            PaginatedViewModel <SongListingViewModel> model =
                ViewModelFactory.CreatePaginatedViewModel <SongListingViewModel>(
                    songsModel,
                    page,
                    DefaultPageSize,
                    songsCount);

            return(View(model));
        }
 public async Task OnGetAsync(
     string sortOrder,
     string currentFilter,
     string searchString,
     int?pageIndex)
 {
     _logger?.LogDebug("'{0}' has been invoked", nameof(OnGetAsync));
     Students = await _mediator.Send(new PaginatedQuery {
         CurrentFilter = currentFilter,
         PageIndex     = pageIndex,
         SearchString  = searchString,
         SortOrder     = sortOrder
     });
 }
        /// <summary>
        /// Displays a listing of all bike racks in the system.
        /// </summary>
        /// <returns></returns>
        public ActionResult rackListing(int page = 1)
        {
            var model = new PaginatedViewModel<BikeRack>();
            model.modelList = context.BikeRack.Where(a => !a.isArchived).ToList();
            foreach(var rack in model.modelList)
            {
                rack.availableBikes = context.Bike.Where(r => r.bikeRackId == rack.bikeRackId).ToList().Where(b => b.isAvailable()).ToList();
            }

            model.pagingInfo = new PageInfo(model.modelList.Count(), model.modelList.Count(), page);
            var images = new Dictionary<int, string>();
            ViewBag.images = images;
            return View(model);
        }
Ejemplo n.º 4
0
        //[ProducesResponseType(typeof(PaginatedItemsViewModel<ProductViewModel>), (int)HttpStatusCode.OK)]
        public async Task <ActionResult <PaginatedViewModel <ProductDto> > > GetProducts([FromQuery] int pageSize = 2, [FromQuery] int pageIndex = 0)
        {
            var totalItems = await _context.Products.LongCountAsync();

            var itemsOnPage = await _context.Products
                              .OrderBy(c => c.Id)
                              .Skip(pageSize * pageIndex)
                              .Take(pageSize)
                              .ToListAsync();

            var vm = _mapper.Map <List <ProductDto> >(itemsOnPage);

            var result = new PaginatedViewModel <ProductDto>(pageIndex, pageSize, (int)totalItems, vm);

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Displays a listing of all bike racks in the system.
        /// </summary>
        /// <returns></returns>
        public ActionResult rackListing(int page = 1)
        {
            var model = new PaginatedViewModel <BikeRack>();

            model.modelList = context.BikeRack.Where(a => !a.isArchived).ToList();
            foreach (var rack in model.modelList)
            {
                rack.availableBikes = context.Bike.Where(r => r.bikeRackId == rack.bikeRackId).ToList().Where(b => b.isAvailable()).ToList();
            }

            model.pagingInfo = new PageInfo(model.modelList.Count(), model.modelList.Count(), page);
            var images = new Dictionary <int, string>();

            ViewBag.images = images;
            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult Index(int page = 1)
        {
            var events      = _eg.GetAll();
            var itemsPrPage = 8;

            events = events.OrderByDescending(x => x.DateOfEvent).ToList();

            var pagination = new PaginatedViewModel
            {
                ItemsPrPage = itemsPrPage,
                Page        = page,
                Events      = events.Skip((page - 1) * itemsPrPage).Take(itemsPrPage).ToList(),
                TotalEvents = events.Count
            };

            return(View(pagination));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Listar(string nombre, string sort, [FromQuery] int pageSize = 50, [FromQuery] int start = 0,
                                                 CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var result = await _queries.ListarAsync(nombre, sort, pageSize, start, cancellationToken);

                var model = new PaginatedViewModel <UsuarioListDTO>(
                    start, pageSize, result.total, result.data);

                return(Ok(model));
            }
            catch (AuthDomainException ex)
            {
                return(BadRequest(new ErrorViewModel(ex.ErrorId, ex.Message)));
            }
        }
Ejemplo n.º 8
0
        // GET: Admin/Breweries
        public ActionResult Index(int page = 0, int pageSize = Constants.DefaultPageSize, string searchPattern = null)
        {
            var skip      = page * pageSize;
            var breweries = this.breweryService.GetAll(skip, pageSize, x => x.Id, searchPattern);
            var viewModel = new PaginatedViewModel <IBrewery>()
            {
                Items       = breweries,
                CurrentPage = page,
                PageSize    = pageSize,
                TotalCount  = searchPattern == null?this.breweryService.CountAll() : this.breweryService.CountAll(searchPattern)
            };

            if (this.Request.IsAjaxRequest())
            {
                return(this.PartialView("_BreweryList", viewModel));
            }

            return(this.View(viewModel));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Page(
            [FromQuery] string name,
            [FromQuery] Guid?typeId,
            [FromQuery] Guid?brandId,
            [FromQuery] int pageSize  = 10,
            [FromQuery] int pageIndex = 0)
        {
            IQueryable <Item> root = (IQueryable <Item>)_context.Items;

            if (!string.IsNullOrEmpty(name))
            {
                root = root.Where(p => p.Name.StartsWith(name));
            }

            if (typeId.HasValue)
            {
                root = root.Where(ci => ci.ItemCategories.Any(ct => ct.CategoryId == typeId));
            }

            if (brandId.HasValue)
            {
                root = root.Where(ci => ci.BrandId == brandId);
            }

            long totalItems = await root
                              .LongCountAsync();

            List <Item> items = await SetupIncludes(root.Where(i => !i.InActive))
                                .OrderBy(c => c.Name)
                                .Skip(pageSize * pageIndex)
                                .Take(pageSize)
                                .ToListAsync();

            //			ChangeUriPlaceholder(items);

            PaginatedViewModel <ItemDTO> model = new PaginatedViewModel <ItemDTO>(
                pageIndex, pageSize, totalItems, _mapper.Map <List <ItemDTO> >(items));

            return(Ok(model));
        }
Ejemplo n.º 10
0
        // GET: Admin/Users
        public ActionResult Index(int page = 0, int pageSize = Constants.DefaultPageSize, string searchPattern = null)
        {
            page     = page < 0 ? 0 : page;
            pageSize = pageSize < 0 ? 1 : pageSize;
            int totalCount = 0;
            var users      = this.userService.PaginatedUsers(page, pageSize, ref totalCount, searchPattern);

            var viewModel = new PaginatedViewModel <IApplicationUser>()
            {
                Items       = users,
                CurrentPage = page,
                PageSize    = pageSize,
                TotalCount  = totalCount
            };

            if (this.Request.IsAjaxRequest())
            {
                return(this.PartialView("_UserList", viewModel));
            }

            return(this.View("Index", viewModel));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Page([FromQuery] bool?all, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
        {
            IQueryable <Unit> query = _context.Units;

            if (!all.HasValue || all.Value == false)
            {
                query = query
                        .Where(b => !b.InActive);
            }

            long totalItems = await query
                              .LongCountAsync();

            List <Unit> items = await query
                                .OrderBy(b => b.Name)
                                .Skip(pageSize * pageIndex)
                                .Take(pageSize)
                                .ToListAsync();

            PaginatedViewModel <UnitDTO> model = new PaginatedViewModel <UnitDTO>(
                pageIndex, pageSize, totalItems, _mapper.Map <List <UnitDTO> >(items));

            return(Ok(model));
        }
Ejemplo n.º 12
0
 public static Task <PaginatedViewModel <TDestination> > PaginatedListAsync <TDestination>(
     this IQueryable <TDestination> queryable, int pageNumber, int pageSize)
 => PaginatedViewModel <TDestination> .CreateAsync(queryable, pageNumber, pageSize);