示例#1
0
        public ActionResult EditRating(string userName)
        {
            var loggedInUser = _sessionHelper.Get("CurrentUser") as User;

            if (loggedInUser == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            var userToRate = _userManager.GetByUserName(userName);

            if (userToRate == null)
            {
                return(HttpNotFound());
            }

            UserRatingViewModel viewModel = new UserRatingViewModel
            {
                Ratings    = _ratingManager.GetAll(),
                UserRating = _userRatingManger.GetById(loggedInUser.ID, userToRate.ID)
            };

            if (viewModel.UserRating == null)
            {
                return(HttpNotFound());
            }

            return(View(nameof(EditRating), viewModel));
        }