// GET: YesNo public virtual ActionResult Index(Guid id, Guid questionId) { var survey = _db.SurveyInstances.First(s => s.ExternalId == id); var question = survey.QuestionInstances.First(q => q.ExternalId == questionId); var model = new SimpleQuestionFormViewModel() { Title = question.Question.QuestionText, Input = new LookupViewModel() { Value = question.Answer, PossibleValues = new List <LookupItem>() { new LookupItem() { Key = true.ToString(), Description = "Ja" }, new LookupItem() { Key = false.ToString(), Description = "Nee" }, } } }; return(View(model)); }
public virtual async Task <ActionResult> Index(Guid id, Guid questionId, SimpleQuestionFormViewModel form) { var survey = _db.SurveyInstances.First(s => s.ExternalId == id); var question = survey .QuestionInstances .First(q => q.ExternalId == questionId); question.Answer = form.Input.Value; question.State = QuestionState.Answered; await _db.SaveChangesAsync(); return(RedirectToAction(MVC.Survey.Resume(id))); }
public virtual async Task <ActionResult> Index(Guid id, Guid questionId, SimpleQuestionFormViewModel form) { var survey = _db.SurveyInstances.First(s => s.ExternalId == id); var question = survey .QuestionInstances .First(q => q.ExternalId == questionId); //in real life ga je de resultaten iets slimmer stockeren, maar dat mogen jullie zelf uitmodeleren :-) question.Answer = form.Input.Value; question.State = QuestionState.Answered; await _db.SaveChangesAsync(); return(RedirectToAction(MVC.Survey.Resume(id))); }
// GET: YesNo public virtual ActionResult Index(Guid id, Guid questionId) { var survey = _db.SurveyInstances.First(s => s.ExternalId == id); var question = survey.QuestionInstances.First(q => q.ExternalId == questionId); var questionDefinition = (MultipleChoice)question.Question; var model = new SimpleQuestionFormViewModel() { Title = question.Question.QuestionText, Input = new LookupViewModel() { Value = question.Answer, PossibleValues = questionDefinition.PossibleAnswers.Select(a => new LookupItem() { Key = a.Category, Description = a.Category }) } }; return(View(model)); }