Exemplo n.º 1
0
        /// <summary>
        /// 创建题库
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult CreateQuestionRes(QuestionResModel request)
        {
            int createResult = QuestionHelp.AddQuestionRes(request);

            if (createResult == 1)
            {
                return(Json(new { Status = 1, Content = "创建题库成功" }));
            }
            else
            {
                return(Json(new { Status = 0, Content = "创建题库失败" }));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 添加题库
 /// </summary>
 /// <param name="questionres"></param>
 public static int AddQuestionRes(QuestionResModel request)
 {
     try
     {
         var             channalInfo = db.FP_WMS_ChannelInfo.SingleOrDefault(t => t.id == request.channalid);
         FP_WMS_SortInfo sortinfo    = new FP_WMS_SortInfo();
         sortinfo.channelid = request.channalid;
         sortinfo.appid     = int.Parse(channalInfo.sortapps);
         sortinfo.display   = request.display;
         sortinfo.parentid  = request.parentid;
         List <int> parents = new List <int>();
         int        cnd     = request.parentid;
         while (cnd != 0)
         {
             parents.Add(cnd);
             cnd = db.FP_WMS_SortInfo.SingleOrDefault(t => t.id == cnd).parentid.Value;
         }
         parents.Add(cnd);
         string parentlist = "";
         for (int i = 0; i < parents.Count(); i++)
         {
             parentlist += parents[parents.Count() - i - 1];
             if (i < (parents.Count() - 1))
             {
                 parentlist += ",";
             }
         }
         sortinfo.parentlist  = parentlist;
         sortinfo.name        = request.name;
         sortinfo.markup      = request.markup;
         sortinfo.pagesize    = request.pagesize;
         sortinfo.description = request.description;
         sortinfo.icon        = "";
         sortinfo.attach_icon = "";
         sortinfo.img         = "";
         sortinfo.attach_img  = FPRandom.CreateCode(20);
         sortinfo.subcounts   = 0;
         sortinfo.types       = "";
         sortinfo.showtype    = request.showtype;
         sortinfo.otherurl    = "";
         sortinfo.posts       = 0;
         db.FP_WMS_SortInfo.Add(sortinfo);
         db.SaveChanges();
         sortinfo.parentlist += "," + sortinfo.id;
         db.SaveChanges();
         foreach (QuestionType qt in Enum.GetValues(typeof(QuestionType)))
         {
             FP_Exam_SortQuestion sortQuestion = new FP_Exam_SortQuestion();
             sortQuestion.channelid    = sortinfo.channelid;
             sortQuestion.sortid       = sortinfo.id;
             sortQuestion.type         = qt.ToString();
             sortQuestion.typeid       = 0;
             sortQuestion.counts       = 0;
             sortQuestion.questionlist = "";
             db.FP_Exam_SortQuestion.Add(sortQuestion);
             db.SaveChanges();
         }
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }