NuSurvey.Web.Controllers.QuestionController.Details C# (CSharp) Method

Details() public method

#1 GET: /Question/Details/5
public Details ( int id, int categoryId ) : System.Web.Mvc.ActionResult
id int Question Id
categoryId int
return System.Web.Mvc.ActionResult
        public ActionResult Details(int id, int? categoryId)
        {
            var question = _questionRepository.GetNullableById(id);

            if (question == null)
            {
                Message = "Question not found.";
                return this.RedirectToAction<ErrorController>(a => a.Index());
            }

            var viewModel = QuestionDetailViewModel.Create(Repository, question);
            if (categoryId.HasValue && categoryId.Value != 0)
            {
                viewModel.Category = question.Category;
            }

            viewModel.UniqueTags = Repository.OfType<PhotoTag>().Queryable.OrderBy(b => b.Name).Select(a => a.Name).Distinct().ToList();

            return View(viewModel);
        }