Beispiel #1
0
        /// <summary>
        /// 给章节添加题目
        /// </summary>
        /// <returns></returns>
        public bool AddChapterQuestions(ChapterPostModel model)
        {
            W_Chapter paper = Orm.Single <W_Chapter>(x => x.ID == model.ChapterID);

            if (paper == null)
            {
                throw new ApiException("章节不存在或者已删除");
            }

            SqlMapper.BeginTransaction();
            try
            {
                foreach (int questionId in model.questionIds)
                {
                    Orm.Insert <W_Chapter_Question>(new W_Chapter_Question()
                    {
                        Chapter_ID  = model.ChapterID,
                        Question_ID = questionId
                    });
                }
                SqlMapper.CommitTransaction();
            }
            catch
            {
                SqlMapper.RollBackTransaction();
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 导入题目
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public dynamic ImportQuestion(Question model, int System_Station_ID, int accountID)
        {
            string Text = "导入成功";
            bool   flg  = false;

            if (Orm.Single <W_Question>(x => x.Title == model.Title && x.QuestionStore_ID == model.QuestionStore_ID && x.QuestionType_ID == model.QuestionType_ID && x.System_Station_ID == System_Station_ID) != null)
            {
                Text = "题目已存在";
            }
            else
            {
                W_Question question = new W_Question();
                question.AddPerson         = accountID;
                question.AddTime           = DateTime.Now;
                question.Answer            = model.Answer;
                question.AnswerCount       = model.AnswerCount;
                question.Body              = model.Body == null ? "" : model.Body;
                question.Level             = model.Level;
                question.Mark              = model.Mark;
                question.QuestionStore_ID  = model.QuestionStore_ID;
                question.QuestionType_ID   = model.QuestionType_ID;
                question.Title             = model.Title;
                question.System_Station_ID = System_Station_ID;
                flg = Orm.Insert <W_Question>(question) > 0;
                if (!flg)
                {
                    Text = "导入失败";
                }
            }
            return(new { Text = Text, Result = flg });
        }
Beispiel #3
0
        /// <summary>
        /// 添加修改网课章节
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public dynamic SaveCourse_Chapters(W_Course_Chapters Model, int System_Station_ID, int AccountID)
        {
            if (Model.Name == null)
            {
                throw new ApiException("名称不能为空");
            }
            if (Model.ID > 0)
            {
                W_Course_Chapters model = Orm.Single <W_Course_Chapters>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);
                if (model == null)
                {
                    throw new ApiException("未找到对应数据");
                }
                Model.AddPerson         = model.AddPerson;
                Model.AddTime           = model.AddTime;
                Model.System_Station_ID = model.System_Station_ID;
                Model.Valid             = model.Valid;
                Model.Orders            = model.Orders;
                if (Orm.Update(Model) <= 0)
                {
                    throw new ApiException("修改失败,请重试");
                }

                return(GetCourse_ChaptersNodeList(model, "", System_Station_ID));
            }
            else
            {
                Model.System_Station_ID = System_Station_ID;
                Model.AddPerson         = AccountID;
                Model.AddTime           = DateTime.Now;
                Model.Valid             = 1;
                Model.Orders            = SqlMapper.QueryForObject <int>("GetMaxchapterOrders", new { System_Station_ID = System_Station_ID, CID = Model.CID }) + 1;
                return(Orm.Single <W_Course_Chapters>(x => x.ID == (int)Orm.Insert(Model, true) && x.System_Station_ID == System_Station_ID));
            }
        }
Beispiel #4
0
        public void Save()
        {
            lock (m_lock)
            {
                if (NewGuilds.Any())
                {
                    foreach (var newGuild in NewGuilds)
                    {
                        Orm.Insert(GuildManager.MapGuild(newGuild));
                    }
                }

                if (guilds.Any())
                {
                    foreach (var guild in guilds)
                    {
                        Orm.Save(GuildManager.MapGuild(guild.Value));
                    }
                }

                NewGuilds.Clear();
            }
            Console.WriteLine($"{DateTime.Now.ToShortTimeString()} GuildManager: Saved guilds !");
            Task.Factory.StartNewDelayed(60 * 1000, Save);
        }
Beispiel #5
0
        /// <summary>
        /// 添加修改 网课
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="System_Station_ID"></param>
        /// <returns></returns>
        public dynamic SaveCourse(W_Course model, int System_Station_ID, int AccountID)
        {
            if (GetExsitWebCourse(model, System_Station_ID) > 0)
            {
                throw new ApiException("该网课已存在!");
            }
            if (model.ID > 0)
            {
                W_CourseModel Model = GetCourseByID(model.ID, System_Station_ID, "");
                if (Model == null)
                {
                    throw new ApiException("操作失败,未找到对应的数据!");
                }
                model.AddPerson         = Model.AddPerson;
                model.AddTime           = Model.AddTime;
                model.System_Station_ID = Model.System_Station_ID;
                model.Valid             = Model.Valid;

                if (Orm.Update(model) <= 0)
                {
                    throw new ApiException("修改失败");
                }
                return(model);
            }
            else
            {
                model.System_Station_ID = System_Station_ID;
                model.Valid             = 1;
                model.AddTime           = DateTime.Now;
                model.AddPerson         = AccountID;
                return(Orm.Single <W_Course>(x => x.ID == (int)Orm.Insert(model, true) && x.System_Station_ID == System_Station_ID));
            }
        }
Beispiel #6
0
 /// <summary>
 /// 添加修改网课单元
 /// </summary>
 /// <param name="Model"></param>
 /// <param name="System_Station_ID"></param>
 /// <returns></returns>
 public dynamic SaveCourse_Unit_ClassTime(W_Course_Unit_ClassTime Model, int System_Station_ID, int AccountID)
 {
     if (Model.ID == 0)
     {
         Model.System_Station_ID = System_Station_ID;
         Model.AddTime           = DateTime.Now;
         Model.Valid             = 1;
         Model.AddPerson         = AccountID;
         return(Orm.Single <W_Course_Unit_ClassTime>(x => x.ID == (int)Orm.Insert(Model, true) && x.System_Station_ID == System_Station_ID));
     }
     else
     {
         W_Course_Unit_ClassTime list = SqlMapper.QueryForObject <W_Course_Unit_ClassTime>("GetCourseUnitClassTimeByID", new { ID = Model.ID, System_Station_ID = System_Station_ID });
         if (list == null)
         {
             throw new ApiException("操作失败,未找到对应的数据!");
         }
         Model.AddPerson         = list.AddPerson;
         Model.AddTime           = list.AddTime;
         Model.System_Station_ID = list.System_Station_ID;
         if (Orm.Update(Model) <= 0)
         {
             throw new ApiException("修改失败");
         }
         return(Model);
     }
 }
Beispiel #7
0
 /// <summary>
 /// 增加字典详细表  by ljg 20171027
 /// </summary>
 /// <param name="Model"></param>
 /// <returns></returns>
 public bool InsertHDictionary(H_Dictionary_Detail Model)
 {
     if (Orm.Insert(Model) <= 0)
     {
         throw new ApiException("添加失败");
     }
     return(true);
 }
Beispiel #8
0
 public bool AddChapter(W_Chapter model)
 {
     if (string.IsNullOrEmpty(model.Name))
     {
         throw new ApiException("章节名称不能为空");
     }
     return(Orm.Insert(model) > 0);
 }
Beispiel #9
0
        /// <summary>
        /// 自动组卷
        /// </summary>
        /// <param name="examPaperId"></param>
        /// <returns></returns>
        public bool CombinationExamPaper(int examPaperId)
        {
            W_ExamPaper paper = Orm.Single <W_ExamPaper>(x => x.ID == examPaperId);

            if (paper == null)
            {
                throw new ApiException("试卷不存在或者已删除");
            }
            //查出试卷所有题型
            List <W_ExamPaperDetail> paperDetails = Orm.Select <W_ExamPaperDetail>(x => x.ExamPaper_ID == examPaperId).ToList();

            if (paperDetails.Sum(x => x.Sorce * x.Num) < paper.PassScore)
            {
                throw new ApiException("试卷及格分数大于所有试卷题型总分,不符合大自然规律,请确保试卷题型总分大于及格分数再组卷");
            }
            //根据试卷题库ID查出题目
            List <W_Question> questions = Orm.Select <W_Question>(x => x.QuestionStore_ID == paper.QuestionStore_ID).ToList();

            SqlMapper.BeginTransaction();
            try
            {
                //删除原先已组好的试题
                Orm.Delete <W_ExamPaperDetail_Detail>(x => x.ExamPaper_ID == paper.ID);
                //依据试卷题型的题目类型与题目数量组成试卷
                foreach (W_ExamPaperDetail pd in paperDetails)
                {
                    List <W_Question> tempList;
                    if (pd.QuestionType_ID != 7)
                    {
                        tempList = questions.Where(x => x.QuestionType_ID == pd.QuestionType_ID && x.QuestionData_ID == 0).OrderBy(x => Guid.NewGuid()).Take(pd.Num).ToList();
                    }
                    else//组合题
                    {
                        tempList = questions.Where(x => x.QuestionData_ID > 0).OrderBy(x => x.QuestionData_ID).Take(pd.Num).ToList();
                    }
                    if (tempList.Count < pd.Num)
                    {
                        throw new ApiException("组卷失败:" + pd.QuestionType_Name + "题目不够");
                    }
                    foreach (W_Question question in tempList)
                    {
                        Orm.Insert <W_ExamPaperDetail_Detail>(new W_ExamPaperDetail_Detail()
                        {
                            ExamPaper_ID        = paper.ID,
                            ExamPaper_Detail_ID = pd.ID,
                            Question_ID         = question.ID
                        });
                    }
                }
                SqlMapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                SqlMapper.RollBackTransaction();
                throw new ApiException(ex.Message);
            }
            return(true);
        }
Beispiel #10
0
 public bool AddDataInfo(W_DataInfo model)
 {
     if (string.IsNullOrEmpty(model.Title))
     {
         throw new ApiException("标题不能为空");
         //当出现异常后,可以直接抛ApiException,拦截器将会拦截异常,并格式化输出
     }
     return(Orm.Insert(model) > 0);
 }
Beispiel #11
0
 /// <summary>
 /// 添加课程设置
 /// </summary>
 /// <param name="Model"></param>
 /// <returns></returns>
 public bool InsertWConfiguration(W_Configuration Model, int System_Station_ID)
 {
     Model.System_Station_ID = System_Station_ID;
     if (Orm.Insert(Model) <= 0)
     {
         throw new ApiException("添加失败");
     }
     return(true);
 }
Beispiel #12
0
        /// <summary>
        /// 购物车生成订单
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public dynamic AddOrderFromShoppingCar(string StuId, int System_Station_ID)
        {
            List <W_CourseModel> Courses = GetShoppingCar(StuId);

            if (Courses != null && Courses.Count > 0)
            {
                bool     flag  = false;
                DateTime time  = DateTime.Now;
                W_Order  order = new W_Order();
                order.AddTime           = time;
                order.PayTime           = time;
                order.OrderNo           = time.ToString("yyyyMMddHHmmss") + new Random().Next(1000, 9999).ToString();
                order.StuId             = StuId;
                order.System_Station_ID = System_Station_ID;
                decimal sum = Courses.Sum(x => x.Price); //如果定价全部为0
                if (sum == 0)                            //免费课程直接支付成功
                {
                    order.Price        = sum;
                    order.PayStatus    = 1;
                    order.PayTime      = time;
                    order.TicketNumber = time.ToString("yyyyMMddHHmmss") + new Random().Next(1000, 9999).ToString();
                    order.PayType      = 1;
                }
                order.Price   = Courses.Sum(x => ((x.PreferentialPrice > 0 && x.Price > 0) ? x.PreferentialPrice : x.Price));
                order.OrderId = Guid.NewGuid().ToString("N").ToUpper();
                int o_id = (int)Orm.Insert(order, true);
                if (o_id > 0)
                {
                    foreach (W_CourseModel course in Courses)
                    {
                        W_Order_Detail orderdetail = new W_Order_Detail();
                        orderdetail.CID       = o_id;
                        orderdetail.Course_ID = course.ID;
                        orderdetail.Price     = (course.PreferentialPrice > 0 && course.Price > 0) ? course.PreferentialPrice : course.Price;
                        flag = Orm.Insert(orderdetail) > 0;
                        if (!flag)
                        {
                            DeleteOrder(order.ID, System_Station_ID);
                            break;
                        }
                    }
                    if (flag)//清空购物车
                    {
                        ClearShoppingCar(StuId);
                    }
                    return(order);
                }
                else
                {
                    throw new ApiException("下单失败");
                }
            }
            else
            {
                throw new ApiException("您的购物车空空如也");
            }
        }
Beispiel #13
0
        /// <summary>
        /// 创建目录并保存 hx add 20180105
        /// </summary>
        /// <param name="Message">创建消息</param>
        /// <param name="PolyvInfo_ID">主表ID</param>
        /// <param name="cataid">分类cataid</param>
        /// <param name="Valid">禁用/启用</param>
        /// <param name="PolyvSource"></param>
        /// <param name="IsAdd">是添加还是修改</param>
        /// <returns></returns>
        public dynamic SavePolyvDetail(bool isAdd, int Station_ID, int PolyvInfo_ID, string cataid, int Valid, int PolyvSource)
        {
            bool save = false;

            W_PolyvInfo_Detail PolyvInfoModel_Detail = new W_PolyvInfo_Detail();

            //明细表添加数据
            PolyvInfoModel_Detail.System_Station_ID = Station_ID;
            PolyvInfoModel_Detail.PolyvInfo_ID      = PolyvInfo_ID;
            PolyvInfoModel_Detail.cataid            = cataid;
            PolyvInfoModel_Detail.Valid             = Valid;
            try
            {
                SqlMapper.BeginTransaction();//开启事务

                if (isAdd)
                {
                    //添加明细数据
                    Orm.Insert(PolyvInfoModel_Detail);

                    //修改配置表账号类型
                    if (SqlMapper.Update("UpdatePolyvinfoType", new { PolyvinfoType = PolyvSource, System_Station_ID = Station_ID }) > 0)
                    {
                        save = true;
                    }
                }
                else
                {
                    //修改明细数据
                    if (SqlMapper.Update("UpdatePolyvInfoDetail", new { PolyvInfo_ID = PolyvInfo_ID, cataid = cataid, Valid = Valid, System_Station_ID = Station_ID }) > 0)
                    {
                        if (SqlMapper.Update("UpdatePolyvinfoType", new { PolyvinfoType = PolyvSource, System_Station_ID = Station_ID }) > 0)
                        {
                            save = true;
                        }
                    }
                    else
                    {
                        throw new ApiException("设置不成功,明细修改异常!");
                    }
                }

                SqlMapper.CommitTransaction();
            }
            catch (Exception ex)
            {
                SqlMapper.RollBackTransaction();
                throw new ApiException(ex.Message);
            }
            finally
            {
                //SqlMapper.CloseConnection();
            }

            return(save);
        }
Beispiel #14
0
 /// <summary>
 /// 添加回复
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public dynamic AddContent(W_Course_Interlocution model, int AccountID)
 {
     model.AddTime    = DateTime.Now;
     model.Account_ID = AccountID;
     if (Orm.Insert <W_Course_Interlocution>(model) <= 0)
     {
         throw new ApiException("添加失败,请重试");
     }
     return(true);
 }
Beispiel #15
0
 /// <summary>
 /// 添加问答
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public dynamic AddCourseInterlocution(W_Course_Interlocution model, string StuId)
 {
     model.AddTime    = DateTime.Now;
     model.Student_ID = StuId;
     if (Orm.Insert <W_Course_Interlocution>(model) <= 0)
     {
         throw new ApiException("添加失败,请重试");
     }
     return(true);
 }
Beispiel #16
0
        public JsonResult Insert([FromBody] invoiceView invoice)
        {
            if (invoice.customer == null)
            {
                return(new JsonResult("{ result: invalid input}"));
            }

            long result = Orm.Insert <invoiceView>(invoice);

            return(new JsonResult("{ result: " + 0 + " }"));
        }
Beispiel #17
0
 /// <summary>
 /// 添加评论
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public dynamic AddCourseComment(W_Course_Comment model, string StuId)
 {
     model.AddTime    = DateTime.Now;
     model.Student_ID = StuId;
     model.Valid      = 1;
     if (Orm.Insert <W_Course_Comment>(model) <= 0)
     {
         throw new ApiException("添加失败,请重试");
     }
     return(true);
 }
Beispiel #18
0
 /// <summary>
 /// 添加题库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddQuestionStore(W_QuestionStore model)
 {
     if (string.IsNullOrEmpty(model.Name))
     {
         throw new ApiException("题库名称不能为空");
     }
     if (model.Discipline_ID == 0)
     {
         throw new ApiException("请选择科次");
     }
     return(Orm.Insert(model, true) > 0);
 }
Beispiel #19
0
        /// <summary>
        /// 添加老师子表、学科关系
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool InsertTeacherDetail(TeacherModel model)
        {
            bool add = false;

            T_TeacherInfo_Detail detail = new T_TeacherInfo_Detail();

            detail.Teacher_ID        = model.ID;
            detail.System_Station_ID = model.System_Station_ID;
            detail.AddTime           = model.AddTime;
            detail.AddPerson         = model.AddPerson;
            detail.Valid             = model.Valid;

            int id2 = (int)Orm.Insert(detail, true);

            if (id2 > 0)
            {
                //添加子表成功,添加老师学科关系
                if (model.Teacher_DisciplineIds != null && model.Teacher_DisciplineIds.Length > 0)
                {
                    string[] dics = model.Teacher_DisciplineIds.Split(',');
                    if (dics.Length > 0)
                    {
                        T_TeacherInfo_Detail_Discipline teacherD_Dis = null;
                        foreach (string disciplineId in dics)
                        {
                            if (string.IsNullOrEmpty(disciplineId))
                            {
                                continue;
                            }

                            teacherD_Dis = new T_TeacherInfo_Detail_Discipline();
                            teacherD_Dis.TeacherDetail_ID  = id2;
                            teacherD_Dis.System_Station_ID = model.System_Station_ID;
                            teacherD_Dis.Discipline_ID     = int.Parse(disciplineId);
                            teacherD_Dis.AddTime           = model.AddTime;
                            teacherD_Dis.AddPerson         = model.AddPerson;

                            //添加老师所教学科
                            Orm.Insert(teacherD_Dis);
                        }
                    }
                }

                add = true;
            }
            else
            {
                throw new ApiException("添加老师详细表失败!");
            }

            return(add);
        }
Beispiel #20
0
        /// <summary>
        /// 添加收藏/取消收藏
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddCollection(W_Collection model)
        {
            W_Collection CollectionModel = Orm.Single <W_Collection>(x => x.BusType == model.BusType & x.BusID == model.BusID && x.StuID == model.StuID);

            if (CollectionModel == null)
            {
                return(Orm.Insert(model) > 0);
            }
            else
            {
                return(Orm.Delete <W_Collection>(x => x.BusID == model.BusID && x.StuID == model.StuID && x.BusType == model.BusType) > 0);
            }
        }
Beispiel #21
0
        /// <summary>
        /// 添加修改课件
        /// </summary>
        /// <param name="Model"></param>
        /// <param name="System_Station_ID"></param>
        /// <param name="AccountID"></param>
        /// <returns></returns>
        public dynamic SaveCourseWare(W_CourseWare Model, int System_Station_ID, int AccountID)
        {
            if (Model.ID > 0)
            {
                W_CourseWare model = Orm.Single <W_CourseWare>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);
                if (model == null)
                {
                    throw new ApiException("您要修改的数据不存在");
                }
                Model.AddPerson = model.AddPerson;
                Model.AddTime   = model.AddTime;
                if (Orm.Update(Model) <= 0)
                {
                    throw new ApiException("修改失败");
                }
            }
            else
            {
                Model.System_Station_ID = System_Station_ID;
                Model.AddTime           = DateTime.Now;
                Model.Valid             = 1;
                Model.Status            = 0;
                Model.Duration          = 0;
                Model.PlayCount         = 0;

                Model.AddPerson = AccountID;
                //去掉后缀
                if (Model.Name != null && Model.Name.Contains("."))
                {
                    Model.Name = Model.Name.Split('.')[0];
                }

                int count = SqlMapper.QueryForObject <int>("GetW_CourseWareCount", new { PolyvVID = Model.PolyvVID });
                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    if (Orm.Insert(Model) <= 0)
                    {
                        throw new ApiException("添加失败");
                    }
                    return(true);
                }
            }
            return(true);
        }
Beispiel #22
0
 /// <summary>
 /// 添加修改网课单元
 /// </summary>
 /// <param name="Model"></param>
 /// <returns></returns>
 public dynamic SaveCourse_Unit(W_Course_Unit Model, int System_Station_ID, int AccountID)
 {
     if (Model.ID > 0)
     {
         W_Course_Unit model = Orm.Single <W_Course_Unit>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);
         if (model == null)
         {
             throw new ApiException("找不到对应数据,请重试");
         }
         Model.System_Station_ID = model.System_Station_ID;
         Model.AddPerson         = model.AddPerson;
         Model.AddTime           = model.AddTime;
         Model.Valid             = model.Valid;
         Model.Orders            = model.Orders;
         if (Orm.Update(Model) <= 0)
         {
             throw new ApiException("修改失败");
         }
         Course_UnitModel m = SqlMapper.QueryForObject <Course_UnitModel>("SelectCourse_Unit", new  { ID = model.ID, System_Station_ID = System_Station_ID });
         if (m != null)
         {
             //单元课次
             List <W_Course_Unit_ClassTime> UnitClassTimeList = new List <W_Course_Unit_ClassTime>();
             //对应单元集合
             UnitClassTimeList = GetCourseUnitClassTimeList(Model, m.ID.ToString());
             if (UnitClassTimeList != null && UnitClassTimeList.Count > 0)
             {
                 m.UnitClassTimeList = UnitClassTimeList.FindAll(X => X.Unit_ID == m.ID);
             }
         }
         return(m);
     }
     else
     {
         Model.AddPerson         = AccountID;
         Model.System_Station_ID = System_Station_ID;
         Model.AddTime           = DateTime.Now;
         Model.Valid             = 1;
         int Orders = SqlMapper.QueryForObject <int>("GetMaxCourseUnit", new { Course_ID = Model.Course_ID, System_Station_ID = System_Station_ID });
         Model.Orders = Orders + 1;
         int modelid = (int)Orm.Insert(Model, true);
         if (modelid <= 0)
         {
             throw new ApiException("添加失败");
         }
         return(Orm.Single <W_Course_Unit>(x => x.ID == modelid && x.System_Station_ID == System_Station_ID));
     }
 }
Beispiel #23
0
 /// <summary>
 /// 添加试卷题型
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddExamPaperDetail(W_ExamPaperDetail model)
 {
     if (model.QuestionType_ID == 0)
     {
         throw new ApiException("题型不能为空");
     }
     if (model.Num <= 0)
     {
         throw new ApiException("题目数量不能小于1");
     }
     if (model.Sorce < 0)
     {
         throw new ApiException("题目分数不能小于0");
     }
     return(Orm.Insert(model) > 0);
 }
Beispiel #24
0
        /// <summary>
        /// //点赞&取消点赞
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public bool UpdateCommentThumbsup(CampusModel model, string StuId)
        {
            W_Comment_Thumbsup ThumbsupModel = Orm.Single <W_Comment_Thumbsup>(x => x.Comment_ID == model.Comment_ID && x.Student_ID == StuId);

            if (ThumbsupModel == null)
            {
                W_Comment_Thumbsup Model = new W_Comment_Thumbsup();
                Model.Comment_ID = model.Comment_ID;
                Model.Student_ID = StuId;
                Model.AddTime    = DateTime.Now;
                return(Orm.Insert <W_Comment_Thumbsup>(Model) > 0);
            }
            else
            {
                return(Orm.Delete <W_Comment_Thumbsup>(x => x.Student_ID == StuId && x.Comment_ID == model.Comment_ID) > 0);
            }
        }
Beispiel #25
0
        /// <summary>
        /// 加入购物车  hx add 2018-01-13
        /// </summary>
        /// <returns></returns>
        public dynamic PutInShoppingCar(string Course_IDs, string StuId)
        {
            bool put = false;

            if (string.IsNullOrEmpty(Course_IDs))
            {
                throw new ApiException("参数Course_IDs为空!");
            }

            if (string.IsNullOrEmpty(StuId))
            {
                throw new ApiException("参数StuId为空!");
            }

            string[] arr = Course_IDs.Split(',');
            if (arr.Length > 0)
            {
                try
                {
                    SqlMapper.BeginTransaction();//开启事务
                    foreach (string id in arr)
                    {
                        if (id != null)
                        {
                            W_Shoppingcar model = new W_Shoppingcar();
                            model.Student_ID = StuId;
                            model.Course_ID  = int.Parse(id);
                            Orm.Insert <W_Shoppingcar>(model);
                        }
                    }
                    put = true;
                    SqlMapper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    SqlMapper.RollBackTransaction();
                    throw new ApiException(ex.Message);
                }
                finally
                {
                    //SqlMapper.CloseConnection();
                }
            }
            return(put);
        }
Beispiel #26
0
        /// <summary>
        /// 给试卷题型添加题目
        /// </summary>
        /// <returns></returns>
        public bool AddPaperDetailQuestions(ExamPaperPostModel model)
        {
            W_ExamPaper paper = Orm.Single <W_ExamPaper>(x => x.ID == model.examPaperId);

            if (paper == null)
            {
                throw new ApiException("试卷不存在或者已删除");
            }
            W_ExamPaperDetail paperDetail = Orm.Single <W_ExamPaperDetail>(x => x.ID == model.examPaperDetailId);

            if (paperDetail == null)
            {
                throw new ApiException("试卷题型不存在或者已删除");
            }
            if (paperDetail.ExamPaper_ID != paper.ID)
            {
                throw new ApiException("试卷题型与试卷不匹配");
            }
            List <W_ExamPaperDetail_Detail> list = Orm.Select <W_ExamPaperDetail_Detail>(x => x.ExamPaper_ID == model.examPaperId && x.ExamPaper_Detail_ID == model.examPaperDetailId).ToList();

            if (list.Count + model.questionIds.Length > paperDetail.Num)
            {
                throw new ApiException("选择的题目不能超过配置的数目");
            }
            SqlMapper.BeginTransaction();
            try
            {
                foreach (int questionId in model.questionIds)
                {
                    Orm.Insert <W_ExamPaperDetail_Detail>(new W_ExamPaperDetail_Detail()
                    {
                        ExamPaper_ID        = model.examPaperId,
                        ExamPaper_Detail_ID = model.examPaperDetailId,
                        Question_ID         = questionId
                    });
                }
                SqlMapper.CommitTransaction();
            }
            catch
            {
                SqlMapper.RollBackTransaction();
                return(false);
            }
            return(true);
        }
Beispiel #27
0
        /// <summary>
        /// 添加题目
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddQuestion(W_Question model)
        {
            if (string.IsNullOrEmpty(model.Title))
            {
                throw new ApiException("题目不能为空");
            }
            W_QuestionStore store = Orm.Single <W_QuestionStore>(x => x.ID == model.QuestionStore_ID);

            if (store.Valid == 0)
            {
                throw new ApiException("选择的题库已被禁用,请重试");
            }
            if (string.IsNullOrEmpty(model.Body))
            {
                model.Body = "";
            }
            return(Orm.Insert(model, true) > 0);
        }
Beispiel #28
0
        /// <summary>
        ///添加修改校区
        /// </summary>
        public bool SaveCampus(W_Campus Model, int AccountID, int System_Station_ID)
        {
            ///判断数据是否存在
            W_Campus model = Orm.Single <W_Campus>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);

            if (Model.ID > 0)//修改
            {
                if (model.Name == Model.Name)
                {
                    throw new ApiException("校区已存在请重新添加");
                }
                if (model == null)
                {
                    throw new ApiException("操作失败,未找到对应的数据!");
                }
                Model.System_Station_ID = model.System_Station_ID;
                Model.AddPerson         = model.AddPerson;
                Model.AddTime           = model.AddTime;
                Model.Valid             = model.Valid;
                if (Orm.Update(Model) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else//添加
            {
                Model.AddPerson         = AccountID;
                Model.AddTime           = DateTime.Now;
                Model.Valid             = 1;
                Model.System_Station_ID = System_Station_ID;
                if (Orm.Insert(Model) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #29
0
 /// <summary>
 /// 章节选择题目
 /// </summary>
 /// <param name="chapterId"></param>
 /// <param name="list"></param>
 /// <returns></returns>
 public bool CheckChapterQuestion(int chapterId, List <Question> list)
 {
     SqlMapper.BeginTransaction();
     try
     {
         foreach (Question question in list)
         {
             Orm.Insert <W_Chapter_Question>(new W_Chapter_Question()
             {
                 Chapter_ID  = chapterId,
                 Question_ID = question.ID
             });
         }
         SqlMapper.CommitTransaction();
     }
     catch
     {
         SqlMapper.RollBackTransaction();
         return(false);
     }
     return(true);
 }
Beispiel #30
0
        /// <summary>
        /// 添加试卷
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool AddExamPaper(W_ExamPaper model)
        {
            if (string.IsNullOrEmpty(model.Title))
            {
                throw new ApiException("试卷名称不能为空");
            }
            if (model.Time < 0)
            {
                throw new ApiException("考试时间必须大于等于0");
            }
            if (model.PassScore < 0)
            {
                throw new ApiException("合格分数必须大于等于0");
            }
            W_QuestionStore store = Orm.Single <W_QuestionStore>(x => x.ID == model.QuestionStore_ID);

            if (store.Valid == 0)
            {
                throw new ApiException("选择的题库已被禁用,请重试");
            }
            return(Orm.Insert(model, true) > 0);
        }