public QuestionTemplateDTO SaveQuestionTemplate(QuestionTemplateDTO dto)
        {
            using (var context = new QuestionnaireEntities())
            {
                Question_Template dao = null;
                if (dto.QuestionTemplateID > 0)
                {
                    dao = context.Question_Template.Find(dto.QuestionTemplateID);
                }
                else
                {
                    dao = new Question_Template()
                    {
                        LastRenderDate = DateTime.Now
                    };
                    context.Question_Template.Add(dao);
                }

                dao.Name             = dto.Name;
                dao.Template         = dto.Template;
                dao.Question_Type_ID = dto.QuestionTypeID;
                dao.LastRenderDate   = dto.LastRenderDate;

                context.SaveChanges();
                dto.QuestionTemplateID = dao.Question_Template_ID;
                QuestionnaireCacheManager.Instance.ClearQuestion(dto.QuestionTemplateID);
            }
            return(dto);
        }
예제 #2
0
 public ActionResult EditQuestionTemplate(int questionTemplateId, QuestionTemplateDTO dto)
 {
     if (ModelState.IsValid)
     {
         QuestionnaireBusinessManager.Instance.SaveQuestionTemplate(dto);
         return(RedirectToAction("ListQuestionTemplates"));
     }
     else
     {
         AddAdditionalViewDataForQuestionTemplate();
         return(View(dto));
     }
 }
        public QuestionTemplateDTO LoadQuestionTemplate(int questionTemplateId)
        {
            QuestionTemplateDTO result = null;

            using (var context = new QuestionnaireEntities())
            {
                var dao = context.Question_Template.Find(questionTemplateId);
                if (dao != null)
                {
                    result = AutoMapper.Mapper.Map <Question_Template, QuestionTemplateDTO>(dao);
                }
            }
            return(result);
        }
예제 #4
0
        public ActionResult EditQuestionTemplate(int questionTemplateId)
        {
            QuestionTemplateDTO dto = QuestionnaireBusinessManager.Instance.LoadQuestionTemplate(questionTemplateId);

            if (dto != null)
            {
                AddAdditionalViewDataForQuestionTemplate();
                return(View(dto));
            }
            else
            {
                throw new HttpException("Unable to load question template id " + questionTemplateId.ToString());
            }
        }
예제 #5
0
 public QuestionTemplateDTO SaveQuestionTemplate(QuestionTemplateDTO dto)
 {
     return(QuestionnaireDataManager.Instance.SaveQuestionTemplate(dto));
 }