public ActionResult DeletePending(int id, bool fromAdmin)
{
var surveyResponse = _surveyResponseRepository.GetNullableById(id);
if (surveyResponse == null || !surveyResponse.IsPending)
{
Message = "Pending survey not found";
return this.RedirectToAction<ErrorController>(a => a.Index());
}
if (!CurrentUser.IsInRole(RoleNames.Admin) && surveyResponse.UserId.ToLower() != CurrentUser.Identity.Name.ToLower())
{
Message = "Not your survey";
return this.RedirectToAction<ErrorController>(a => a.NotAuthorized());
}
var viewModel = SingleAnswerSurveyResponseViewModel.Create(Repository, surveyResponse.Survey, surveyResponse);
viewModel.FromAdmin = fromAdmin;
return View(viewModel);
}