public ActionResult Details(int?id) { ApplicationUser user = _userService.FindActive(id); if (user == null) { return(NotFound()); } var playtimes = _reviewService.UserPlaytimeList(user.Id).AsQueryable(); var gamelists = _gameListService.GetAll().Where(u => u.UserList.UserId == user.Id).ToList(); UserProfileViewModel model = new UserProfileViewModel { AppUser = user, GameLists = gamelists.ToList(), ReviewsPlaytimes = PaginatedList <ReviewPlaytime> .Create(playtimes.AsNoTracking(), null, null), RecentlyUpdatedGames = _gameListService.GetRecentUserGameListUpdates(user.Id, 3), ListTypes = _listTypeService.GetAll().ToList() }; model.ReviewsPlaytimes.Pagination.Action = this.ControllerContext.ActionDescriptor.ActionName.ToString();; ViewBag.IsOwner = _userService.IsOwner(id); return(View(model)); }
public IViewComponentResult Invoke(int?gameid) { if (!gameid.HasValue) { gameid = 0; } var userid = _userService.GetLoggedInUserId(); var userLists = _userListService.GetUserUserLists(userid).ToList(); var gameList = TempData.Get <GameList>("gameList"); if (TempData["GameListId"] != null) { var gamelistid = TempData["GameListId"] as int?; if (gamelistid.HasValue) { gameList.Id = gamelistid.Value; } } if (gameList != null) { var errors = _gameListService.ValidateGameList(gameList); ModelState.Merge(errors); } if (gameList == null) { gameList = _gameListService.GetAll().FirstOrDefault(g => g.GameId == gameid && g.UserList.UserId == userid); } if (gameList == null) { gameList = new GameList(); } ViewBag.UserListId = userLists; ViewBag.GameId = gameid; ViewBag.Id = gameList.Id; return(View("_AddGameToUserList", gameList)); }
public IViewComponentResult Invoke(int userid, int?gamelistid) { var userLists = _userListService.GetUserUserLists(userid).ToList(); var gameList = TempData.Get <GameList>("gameList"); if (gameList != null && gamelistid.HasValue) { if (gameList.Id != gamelistid) { gameList = null; } } if (gameList != null) { var errors = _gameListService.ValidateGameList(gameList); ModelState.Merge(errors); } if (gameList == null) { gameList = _gameListService.GetAll().SingleOrDefault(g => g.Id == gamelistid); } if (gameList == null) { gameList = new GameList(); } ViewBag.UserListId = userLists; ViewBag.Id = gameList.Id; ViewBag.Games = _gameService.GetAllActive(); return(View("_UserGameListForm", gameList)); }