Exemplo n.º 1
0
        public ActionResult Edit(int surveyId)
        {
            var survey       = _psychologistManager.GetSurvey(surveyId);
            var allQuestions = _psychologistManager.GetAllQuestions();

            if (survey != null && survey.Author.Id == User.Identity.GetUserId())
            {
                EditSurveyViewModel editVM = new EditSurveyViewModel()
                {
                    Survey    = survey,
                    Questions = new List <CreateSurveyViewModel>()
                };

                foreach (var question in allQuestions)
                {
                    editVM.Questions.Add(new CreateSurveyViewModel
                    {
                        Question    = question,
                        AddToSurvey = survey.Questions.Any(x => x.Id == question.Id),
                    });
                }
                return(View(editVM));
            }
            else
            {
                return(RedirectToAction("Psychologist", "Home"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(EditSurveyViewModel editVM)
        {
            var newQuestions = editVM.Questions.Where(x => x.AddToSurvey == true)
                               .Select(x => x.Question)
                               .ToList();

            _psychologistManager.EditSurvey(newQuestions, editVM.Survey.Id);

            return(RedirectToAction("Manage"));
        }
Exemplo n.º 3
0
        public IActionResult Edit(int?id = 1)
        {
            var survey          = surveyService.GetById(id.Value);
            var surveyViewModel = new EditSurveyViewModel(survey);

            //var customer = customerService.GetById(survey.CustomerId);
            //var surveyTemplate = surveyTemplateService.GetById(1);
            //if (survey.SurveyTemplateId > 0)
            //{
            //    if (surveyTemplate.SectionGroup != null)
            //    {
            //        var answerGroupList = new List<AnswerGroupViewModel>();
            //        foreach (var answerGroup in survey.AnswerGroup)
            //        {
            //            answerGroupList.Add(new AnswerGroupViewModel(answerGroup));
            //        }
            //        surveyViewModel.AnswerGroups = answerGroupList;
            //    }
            //}
            //surveyViewModel.Customer = customer;
            return(View(surveyViewModel));
        }