public async Task <ViewResult> Edit(string currentFilter, string searchString,
                                            int?pageNumber)
        {
            if (searchString != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewData["CurrentFilter"] = searchString;
            var currentUserId  = GetCurrentUserId().Result;
            var availableGames = _shelfRepository.GetAvailableGamesForUser(currentUserId).OrderBy(g => g.Title);

            if (!string.IsNullOrEmpty(searchString))
            {
                availableGames = availableGames.Where(g => g.Title.Contains(searchString)).OrderBy(g => g.Title);
            }

            var mv = new ShelfEditViewModel
            {
                AvailableGames =
                    await PaginatedList <Game> .CreateAsync(availableGames, pageNumber ?? 1, Constants.PicturesNumber)
            };

            return(View(mv));
        }
示例#2
0
        public ViewResult Edit()
        {
            var currentUserId = GetCurrentUserId().Result;
            var mv            = new ShelfEditViewModel
            {
                Shelf          = _shelfRepository.GetShelfForUser(currentUserId),
                AvailableGames = _shelfRepository.GetAvailableGamesForUser(currentUserId)
            };

            return(View(mv));
        }