public ActionResult Create([Bind(Include = "Name")] QuestionTypeVM questionTypeVM) { if (ModelState.IsValid) { QuestionTypeDTO questionTypeDTO = Mapper.Map <QuestionTypeDTO>(questionTypeVM); QuestionTypeService.Add(questionTypeDTO); return(RedirectToAction("Index")); } return(View()); }
// TypeChooser To CreateEditQuestionView (Make new question) private void CreateQuestion(string type) { SelectedQuestion = new QuestionVM { Type = type }; SelectedType = new QuestionTypeVM { Type = type }; new ViewModelLocator().OptionHandlerViewModel.SetOptions(type); SwitchView = 3; }
// Edit question private void EditQuestion(int index) { SelectedQuestion = new QuestionVM(SelectedQuestionList.Questions.FirstOrDefault(i => i.Index == index)); SelectedType = new QuestionTypeVM { Type = SelectedQuestion.Type }; if (SelectedQuestion.QuestionOptions != null) { new ViewModelLocator().OptionHandlerViewModel.SetOptions(SelectedType.Type); } SwitchView = 3; }
public ActionResult Edit(int?id) { try { QuestionTypeDTO questionTypeDTO = QuestionTypeService.Get(id); QuestionTypeVM questionTypeVM = Mapper.Map <QuestionTypeVM>(questionTypeDTO); return(View(questionTypeVM)); } catch (ArgumentNullException) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } catch (NotFoundException) { return(HttpNotFound()); } }