public async Task <IActionResult> OnGetAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToPage("/Account/Login")); } Game = await _context.GetGameAsync(Id); if (Game == null) { return(NotFound()); } Game.Rating = await _context.GetTotalGameRatingAsync(Game); CanReview = await _context.DoesUserOwnGameAsync(user, Game); Reviews = await _context.GetGameReviewsAsync(Game); Review = Reviews.FirstOrDefault(r => r.Reviewer == user); HasReview = Review == null ? false : true; return(Page()); }
public async Task <IActionResult> OnGetAsync(Guid?id) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToPage("/Account/Login")); } if (id == null) { return(RedirectToPage("/Admin/Games/Index")); } Game = await _context.Games .Include(g => g.Category) .FirstOrDefaultAsync(m => m.Id == id); if (Game == null) { return(RedirectToPage("/Admin/Games/Index")); } Game.Rating = await _context.GetTotalGameRatingAsync(Game); return(Page()); }
public async Task <IActionResult> OnGetAsync(string statusMessage) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(RedirectToPage("/Account/Login")); } IQueryable <Game> games = from ug in _context.UserGames where ug.UserId == user.Id select ug.Game; games = games.Include(g => g.Category).Include(g => g.Platform); IQueryable <Category> categories = _context.Categories; Categories = categories .Select(x => new SelectListItem() { Text = x.Name, Value = x.Name }) .ToList(); if (!string.IsNullOrEmpty(Search)) { games = games.Where(x => x.Title.Contains(Search.Trim())); } if (!string.IsNullOrEmpty(Category)) { games = games.Where(x => x.Category.Name.Contains(Category.Trim())); } foreach (var game in games) { game.Rating = await _context.GetTotalGameRatingAsync(game); } Games = await games.ToListAsync(); StatusMessage = !string.IsNullOrEmpty(statusMessage) ? statusMessage : ""; return(Page()); }