Example #1
0
        public ActionResult Manage(int?page, int?items, string sortOrder, string currentFilter)
        {
            ViewData["IdSortParm"]       = String.IsNullOrEmpty(sortOrder) ? "id_desc" : "";
            ViewData["UserSortParm"]     = sortOrder == "user" ? "user_desc" : "user";
            ViewData["GameSortParm"]     = sortOrder == "game" ? "game_desc" : "game";
            ViewData["AddDateSortParm"]  = sortOrder == "adddate" ? "adddate_desc" : "adddate";
            ViewData["EditDateSortParm"] = sortOrder == "editdate" ? "editdate_desc" : "editdate";
            ViewData["ScoreSortParm"]    = sortOrder == "score" ? "score_desc" : "score";
            ViewData["HoursSortParm"]    = sortOrder == "hours" ? "hours_desc" : "hours";
            ViewData["ListSortParm"]     = sortOrder == "list" ? "list_desc" : "list";

            var gameLists = _gameListService.FilterSearch(currentFilter);

            gameLists = _gameListService.SortList(sortOrder, gameLists);

            var result = PaginatedList <GameList> .Create(gameLists.AsNoTracking(), page, items);

            result.Pagination.Configure(
                this.ControllerContext.ActionDescriptor.ActionName.ToString(), currentFilter, sortOrder);
            return(View(result));
        }
        public ActionResult GameLists(int?id, int?page, int?items, string sortOrder, string filterType, string currentFilter)
        {
            ViewData["TitleSortParm"] = String.IsNullOrEmpty(sortOrder) ? "game_desc" : null;
            ViewData["NameSortParm"]  = sortOrder == "Name" ? "Name_desc" : "Name";
            ViewData["ScoreSortParm"] = sortOrder == "score" ? "score_desc" : "score";
            ViewData["HoursSortParm"] = sortOrder == "hours" ? "hours_desc" : "hours";

            var LoggedUserId = _userService.GetLoggedInUserId();

            if (!id.HasValue)
            {
                id = LoggedUserId;
            }
            var user = _userService.Find(id);

            if (user == null || !id.HasValue)
            {
                return(NotFound());
            }

            IQueryable <GameList> gamelists = _gameListService.OwnerGameLists(id);

            gamelists = _gameListService.FilterByList(filterType, currentFilter, gamelists);
            gamelists = _gameListService.SortList(sortOrder, gamelists);

            var model = new UserGameListsViewModel
            {
                AppUser      = user,
                ListTypes    = _listTypeService.GetAll().ToList(),
                GameLists    = PaginatedList <GameList> .Create(gamelists.AsNoTracking(), page, items),
                LoggedUserId = LoggedUserId
            };

            model.GameLists.Pagination.Configure(
                this.ControllerContext.ActionDescriptor.ActionName.ToString(), id, filterType, currentFilter, sortOrder);
            ViewBag.IsOwner = _userService.IsOwner(id);
            return(View(model));
        }