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); }
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); }
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()); } }
public QuestionTemplateDTO SaveQuestionTemplate(QuestionTemplateDTO dto) { return(QuestionnaireDataManager.Instance.SaveQuestionTemplate(dto)); }