示例#1
0
 public bool Edit(QuestionAdminViewModel model)
 {
     try
     {
         var actual = Mapper.Map<Question>(model);
         foreach (var answer in model.Answers)
         {
             if (answer.Id == 0)
             {
                 answer.QuestionId = model.Id;
                 this.AnswerService.Create(answer);
             }
             else
             {
                 this.AnswerService.Edit(answer);
             }
         }
         this.Data.Questions.Update(actual);
         this.Data.SaveChanges();
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
示例#2
0
        public ActionResult Edit(QuestionAdminViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var updatedModel = this.QuestionService.Edit(model);
                if (updatedModel)
                {
                    //return this.RedirectToAction("AddAnswers", "Answer", new { questionId = updatedModel.Id });
                }
            }

            return this.View(model);
        }
示例#3
0
 public QuestionAdminViewModel Create(QuestionAdminViewModel model)
 {
     try
     {
         var actual = Mapper.Map<Question>(model);
         this.Data.Questions.Add(actual);
         this.Data.SaveChanges();
         model.Id = actual.Id;
         return model;
     }
     catch (Exception e)
     {
         return null;
     }
 }
示例#4
0
 public ActionResult Create()
 {
     var model = new QuestionAdminViewModel();
     return this.View(model);
 }