public IActionResult EditQuestionnaire(int questionnaireId)
        {
            Questionnaire q = ModMgr.GetQuestionnaire(questionnaireId, false);

            List <Phase> availablePhases           = new List <Phase>();
            Phase        parentPhase               = ProjMgr.GetPhase(q.ParentPhase.Id);
            List <QuestionnaireQuestion> questions = QqMgr.GetAllByModuleId(questionnaireId).ToList();

            foreach (QuestionnaireQuestion question in questions)
            {
                question.Answers = QqMgr.GetAnswers(question.Id);
            }

            foreach (Phase phase in ProjMgr.GetAllPhases(q.Project.Id).ToList())
            {
                if (ModMgr.GetQuestionnaire(phase.Id, q.Project.Id) == null)
                {
                    availablePhases.Add(phase);
                }
            }

            q.Project.Phases = availablePhases.ToList();
            q.ParentPhase    = parentPhase;
            q.Questions      = questions;

            ViewData["Project"]       = q.Project;
            ViewData["Questionnaire"] = q;
            return(View());
        }
        public IActionResult AddQuestionnaireQuestion(int questionnaireId, QuestionnaireQuestion qQ)
        {
            Questionnaire         toAdd       = ModMgr.GetQuestionnaire(questionnaireId, false);
            QuestionnaireQuestion newQuestion = new QuestionnaireQuestion
            {
                QuestionText  = qQ.QuestionText,
                QuestionType  = qQ.QuestionType,
                Module        = toAdd,
                Questionnaire = toAdd,
                Optional      = qQ.Optional,
                Answers       = new List <Answer>()
            };

            toAdd.Questions.Add(qQ);
            QqMgr.MakeQuestion(newQuestion, toAdd.Id);
            ModMgr.EditQuestionnaire(toAdd);

            return(RedirectToAction("AddQuestionnaire", toAdd.Id));
        }
        public IActionResult AddQuestionnaire(int projectId)
        {
            Project toAddQuestionnaireTo = ProjMgr.GetProject(projectId, true);

            List <Phase> availablePhases = new List <Phase>();

            foreach (Phase phase in ProjMgr.GetAllPhases(projectId).ToList())
            {
                if (ModMgr.GetQuestionnaire(phase.Id, projectId) == null)
                {
                    availablePhases.Add(phase);
                }
            }

            toAddQuestionnaireTo.Phases = availablePhases.ToList();

            ViewData["project"] = toAddQuestionnaireTo;


            return(View());
        }
        public IActionResult EditQuestionnaire(EditQuestionnaireModel eqm, int questionnaireid)
        {
            Questionnaire toBeUpdated = ModMgr.GetQuestionnaire(questionnaireid, false);

            Phase  parentPhase        = new Phase();
            String parentPhaseContent = Request.Form["ParentPhase"];

            if (!parentPhaseContent.Equals(""))
            {
                parentPhase        = ProjMgr.GetPhase(Int32.Parse(Request.Form["ParentPhase"].ToString()));
                parentPhase.Module = toBeUpdated;

                Phase previousParent = ProjMgr.GetPhase(toBeUpdated.ParentPhase.Id);
                previousParent.Module = null;


                toBeUpdated.ParentPhase = parentPhase;
                ProjMgr.EditPhase(previousParent);
            }
            else
            {
                parentPhase = toBeUpdated.ParentPhase;
            }

            if (eqm.VoteLevel != null)
            {
                toBeUpdated.VoteLevel = eqm.VoteLevel;
            }

            toBeUpdated.OnGoing = eqm.OnGoing;
            toBeUpdated.Title   = eqm.Title;

            ModMgr.EditQuestionnaire(toBeUpdated);

            return(RedirectToAction("EditQuestionnaire", new { questionnaireId = questionnaireid }));
        }
 public IActionResult AddQuestionnaireQuestion(int questionnaireid)
 {
     ViewData["Questionnaire"] = ModMgr.GetQuestionnaire(questionnaireid, false);
     return(View(new QuestionnaireQuestion()));
 }