Ejemplo n.º 1
0
        /// <summary>
        /// 拖拽排序(拖拽完就保存)
        /// </summary>
        /// <param name="new_prev_order">拖拽后上节点排序值</param>
        /// <param name="currDisciplineId">当前被拖拽ID</param>
        /// <param name="currParentId">当前被拖拽ID的父ID</param>
        /// <returns></returns>
        public bool MoveChapter(SortDisciplineModel model, int System_Station_ID)
        {
            SqlMapper.BeginTransaction();
            try
            {
                W_Course_Chapters ChapterModel = Orm.Single <W_Course_Chapters>(x => x.ID == model.currDisciplineId && x.System_Station_ID == System_Station_ID);
                if (ChapterModel == null)
                {
                    throw new ApiException("请刷新重试,您要操作的数据不存在");
                }

                if (model.currParentId == 0)
                {
                    SqlMapper.Update("MoveChapter", new { new_prev_order = model.new_prev_order, currParentId = 0, currDisciplineId = model.currDisciplineId, System_Station_ID = System_Station_ID });
                }
                else if (model.currParentId > 0)
                {
                    SqlMapper.Update("MoveChapter", new { currParentId = model.currParentId, new_prev_order = model.new_prev_order, currDisciplineId = model.currDisciplineId, System_Station_ID = System_Station_ID });
                }
                SqlMapper.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                SqlMapper.RollBackTransaction();
                throw ex;
            }
        }
Ejemplo n.º 2
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));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据网课id查找对应的章节  分子父节点
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public dynamic GetCourse_ChaptersNodeList(W_Course_Chapters model, string StuId, int System_Station_ID)
        {
            List <Course_ChaptersModel> List     = SqlMapper.QueryForList <Course_ChaptersModel>("GetCourse_ChaptersList", new { System_Station_ID = System_Station_ID, StuId = StuId, Course_ID = model.Course_ID, CID = model.CID, Valid = model.Valid }).ToList();
            List <Course_ChaptersModel> NodeList = new List <Course_ChaptersModel>();

            if (List != null && List.Count > 0)
            {
                NodeList = List.FindAll(X => X.CID == 0);
                NodeList.ForEach(x =>
                {
                    x.ChildNodeList = List.FindAll(F => F.CID == x.ID);
                });
            }
            return(NodeList);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 删除课件
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public dynamic DeleteCourseWare(CourseWareModel model, int System_Station_ID)
        {
            W_CourseWare CourseWareModel = Orm.Single <W_CourseWare>(x => x.ID == model.ID && x.System_Station_ID == System_Station_ID);

            if (CourseWareModel == null)
            {
                throw new ApiException("操作失败,未找到操作数据,请刷新重试");
            }
            W_Course_Chapters chaptersmodel = Orm.Single <W_Course_Chapters>(x => x.CourseWare_ID == model.ID && x.System_Station_ID == System_Station_ID);

            if (chaptersmodel != null)
            {
                throw new ApiException("章节应用了该课件,请先删除课件");
            }
            return(Orm.Delete(CourseWareModel));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除网课章节及对应的关系表
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public dynamic DeleteCourseChapters(W_Course_Chapters Model, int System_Station_ID)
        {
            SqlMapper.BeginTransaction();
            try
            {
                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("未找到对应数据,请查看再试");
                }
                Orm.Delete <W_Course_Chapters>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID);
                Orm.Delete <W_DataInfo>(x => x.BusID == Model.ID && x.BusType == 1);

                SqlMapper.CommitTransaction();
                return(true);
            }
            catch (Exception ex)
            {
                SqlMapper.RollBackTransaction();
                throw ex;
            }
        }
Ejemplo n.º 6
0
 public dynamic DeleteCourseChapters(W_Course_Chapters Model)
 {
     return(Success(mapper.DeleteCourseChapters(Model, this.System_Station_ID)));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 根据网课id查找对应的章节  分子父节点
 /// </summary>
 /// <returns></returns>
 public dynamic GetCourse_ChaptersNodeList([FromUri] W_Course_Chapters model)
 {
     return(Success(mapper.GetCourse_ChaptersNodeList(model, this.SafeGetStuId, this.System_Station_ID)));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 添加修改网课章节
 /// </summary>
 /// <param name="Model"></param>
 /// <returns></returns>
 public dynamic SaveCourse_Chapters(W_Course_Chapters Model)
 {
     return(Success(mapper.SaveCourse_Chapters(Model, this.System_Station_ID, this.AccountID)));
 }