public ActionResult IndexProfile() { try { var adminEmail = User.Identity.Name; if (adminEmail != null) { var adminReviewsList = _context.Reviews.Include(r => r.product).Where(r => r.ReviewOwner == adminEmail).ToList(); var adminInDb = _context.Users.SingleOrDefault(a => a.UserName == adminEmail); if (adminInDb != null) { var viewModel = new UserReviewsViewModel() { UserReviews = adminReviewsList, Username = adminInDb.UserName, PhoneNumber = adminInDb.PhoneNumber, Email = adminInDb.Email, UserId = adminInDb.Id, UserImageURL = adminInDb.UserImageURL }; return(View(viewModel)); } else { return(Content("Failed")); } } else if (User.Identity.Name != null && User.IsInRole(RoleName.admin)) { return(View()); } else { return(RedirectToAction("Login", "Account")); } } catch { return(View()); } }
public ActionResult Reviews(int?id, int?page, int?items) { var user = _userService.Find(id); if (user == null) { return(NotFound()); } var playtimes = _reviewService.UserPlaytimeList(user.Id).AsQueryable(); var model = new UserReviewsViewModel { AppUser = user, ReviewsPlaytimes = PaginatedList <ReviewPlaytime> .Create(playtimes.AsNoTracking(), page, items) }; model.ReviewsPlaytimes.Pagination.Configure(this.ControllerContext.ActionDescriptor.ActionName.ToString(), id); ViewBag.IsOwner = _userService.IsOwner(id); return(View(model)); }