NuSurvey.Web.Controllers.SurveyResponseController.Results C# (CSharp) Method

Results() public method

#12 Get: /SurveyResponse/Results
public Results ( int id, System.Guid publicGuid ) : System.Web.Mvc.ActionResult
id int SurveyResponse ID
publicGuid System.Guid
return System.Web.Mvc.ActionResult
        public ActionResult Results(int id, Guid? publicGuid)
        {
            var surveyResponse = _surveyResponseRepository.GetNullableById(id);
            if (string.IsNullOrWhiteSpace(CurrentUser.Identity.Name))
            {
                surveyResponse = (SurveyResponse)Session[publicGuid.ToString()];
            }
            if (surveyResponse == null)
            {
                Message = "Not Found";
                return this.RedirectToAction<ErrorController>(a => a.Index());
            }

            if (!CurrentUser.IsInRole(RoleNames.Admin))
            {
                if (!string.IsNullOrWhiteSpace(CurrentUser.Identity.Name))
                {
                    if (surveyResponse.UserId.ToLower() != CurrentUser.Identity.Name.ToLower())
                    {
                        Message = "Not your survey";
                        return this.RedirectToAction<ErrorController>(a => a.NotAuthorized());
                    }
                }
                else
                {
                    if (surveyResponse.UserId.ToLower() != publicGuid.ToString().ToLower())
                    {
                        Message = "Not your survey";
                        return this.RedirectToAction<ErrorController>(a => a.NotAuthorized());
                    }
                }
            }

            var viewModel = ResultsViewModel.Create(surveyResponse, false);
            viewModel.PublicGuid = publicGuid;
            //if (CurrentUser.IsInRole(RoleNames.Admin) || CurrentUser.IsInRole(RoleNames.User))
            //{
                viewModel.ShowPdfPrint = true;
            //}

            return View(viewModel);
        }