示例#1
0
 public ActionResult QuestionItemEdit(SetQuestionViewModel form)
 {
     SetQuestion pp = null;
     if (ModelState.IsValid)
     {
         pp = SetQuestionRepository.GetByKey(form.ID);
         pp.SetQuestionName = form.SetQuestionName;
         pp.IsOther = form.IsOther;
         pp.Status = form.Status;
         pp.Answers = form.Answers;
         pp.Type = form.Type;
         pp.QuestionCategoryID = form.QuestionCategoryID;
         SetQuestionRepository.Update(pp);
         SetQuestionRepository.Context.Commit();
     }
     return Redirect("/Questionnaire/QuestionList?qID=" + pp.QuestionCategoryID);
 }
示例#2
0
        public ActionResult QuestionItemCreate(SetQuestionViewModel form)
        {
            var UserId = WebSecurity.GetUserId(User.Identity.Name);
            form.AddDate = DateTime.Now;
            form.UserId = UserId;
            var ss = SetQuestionRepository.FindAll(Specification<SetQuestion>.Eval(o => o.UserId == UserId && o.QuestionCategoryID == form.QuestionCategoryID)).ToList();

            if (ss.Count() > 0)
            {
                form.OrderIndex = ss.Max(qu => qu.SetQuestionID) + 1;
            }
            else
            {
                form.OrderIndex = 1;
            }

            SetQuestion pp = null;
            if (ModelState.IsValid)
            {
                pp = Mapper.Map<SetQuestionViewModel, SetQuestion>(form);
                SetQuestionRepository.Add(pp);
                SetQuestionRepository.Context.Commit();
            }
            return Redirect("/Questionnaire/QuestionList?qID=" + pp.QuestionCategoryID);
        }