public QuestionUtils()
 {
     defaultModel = new QuestionViewModels
     {
         Answer = ";;;;;",
         Aspect = "",
         Competency = "",
         type = "A",
         Topic = "",
         PID = ProjectId,
         Weight = 0
     };
 }
 public ActionResult QuestionUpdate(QuestionViewModels question)
 {
     string err = "";
     if (!questionUtils.UpdateQuestion(question, out err))
     {
         return Json(new { isErr = true, errMsg = err });
     }
     return Json(new { isErr = false });
 }
 public bool UpdateQuestion(QuestionViewModels model, out string ErrMsg)
 {
     try
     {
         ErrMsg = null;
         using (var ctx = new EvaluationSysEntities())
         {
             var entity = ctx.TopicRecord.FirstOrDefault(a => a.Id == model.Id && a.PID == ProjectId);
             if (entity == null)
                 throw new Exception("No such TopicId");
             if (string.IsNullOrEmpty(model.Topic))
                 throw new Exception("题目不能为空");
             entity.Heading = model.Topic;
             entity.KeyA = model.a ?? "";
             entity.KeyB = model.b ?? "";
             entity.KeyC = model.c ?? "";
             entity.KeyD = model.d ?? "";
             entity.KeyE = model.e ?? "";
             entity.KeyF = model.f ?? "";
             entity.Type = model.type ?? "A";
             entity.Weight = model.Weight;
             entity.Aspect = model.Aspect ?? "";
             entity.Competency = model.Competency ?? "";
             return ctx.SaveChanges() >= 0;
         }
     }
     catch (DbEntityValidationException e)
     {
         string error = "";
         foreach (var i in e.EntityValidationErrors)
         {
             foreach (var j in i.ValidationErrors)
             {
                 error = j.PropertyName + ":" + j.ErrorMessage;
             }
         }
         ErrMsg = error;
         return false;
     }
     catch (Exception ex)
     {
         ErrMsg = ex.GetBaseException().Message;
         return false;
     }
 }