/// <summary> /// 删除网课及对应的关系表 /// </summary> /// <param name="Model"></param> /// <param name="System_Station_ID"></param> /// <returns></returns> public bool DeleteCourse(CampusModel Model, int System_Station_ID) { SqlMapper.BeginTransaction(); try { W_Course model = Orm.Single <W_Course>(x => x.System_Station_ID == System_Station_ID && x.ID == Model.ID); if (model == null) { throw new ApiException("您要操作的数据不存在"); } if (model.Valid == 1) { throw new ApiException("请先禁用,再执行删除操作"); } int count = SqlMapper.QueryForObject <int>("GetCourseOrderCount", new { ID = Model.ID }); if (count > 0) { throw new ApiException("该课程已被网校学生购买无法删除!"); } Orm.Delete <W_Course>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID); Orm.Delete <W_Course_Chapters>(x => x.Course_ID == Model.ID && x.System_Station_ID == System_Station_ID); int isDelete = SqlMapper.QueryForObject <int>("DeleteCourse", new { ID = Model.ID, System_Station_ID = System_Station_ID }); Orm.Delete <W_Course_Unit>(x => x.Course_ID == Model.ID && x.System_Station_ID == System_Station_ID); Orm.Delete <W_DataInfo>(x => x.BusID == Model.ID && x.System_Station_ID == System_Station_ID); SqlMapper.CommitTransaction(); return(true); } catch (Exception ex) { SqlMapper.RollBackTransaction(); throw ex; } }
/// <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)); } }
/// <summary> /// 上架下架网课 /// </summary> /// <param name="Model"></param> /// <param name="System_Station_ID"></param> /// <returns></returns> public bool UpdateCourseIsPutaway(CampusModel Model, int System_Station_ID) { SqlMapper.BeginTransaction(); try { W_Course model = Orm.Single <W_Course>(x => x.System_Station_ID == System_Station_ID && x.ID == Model.ID); if (model == null) { throw new ApiException("您要操作的数据不存在"); } model.IsPutaway = Model.IsPutaway; if (Orm.Update(model) <= 0) { throw new ApiException("修改失败,请重新操作"); } SqlMapper.CommitTransaction(); return(true); } catch (Exception ex) { SqlMapper.RollBackTransaction(); throw ex; } }
public dynamic SaveCourse1(W_Course model) { W_CourseModel Coursemodel = mapper.GetCourseByID(model.ID, this.System_Station_ID, ""); if (Coursemodel != null) { model.TeacherDetail_ID = Coursemodel.TeacherDetail_ID; model.CoverPath = Coursemodel.CoverPath; model.Description = Coursemodel.Description; model.Particulars = Coursemodel.Particulars; } return(Success(mapper.SaveCourse(model, this.System_Station_ID, this.AccountID))); }
public dynamic SaveCourse2(W_Course model) { W_CourseModel Coursemodel = mapper.GetCourseByID(model.ID, this.System_Station_ID, ""); if (Coursemodel != null) { model.Name = Coursemodel.Name; model.Price = Coursemodel.Price; model.PreferentialPrice = Coursemodel.PreferentialPrice; model.BuyBase = Coursemodel.BuyBase; model.TotalHours = Coursemodel.TotalHours; model.TeachingMethod = Coursemodel.TeachingMethod; model.IsPutaway = Coursemodel.IsPutaway; model.IsRecommend = Coursemodel.IsRecommend; model.Discipline_ID = Coursemodel.Discipline_ID; } return(Success(mapper.SaveCourse(model, this.System_Station_ID, this.AccountID))); }
/// <summary> /// 禁用启用网课 /// </summary> /// <param name="Model"></param> /// <param name="System_Station_ID"></param> /// <returns></returns> public bool UpdateCourseValid(CampusModel Model, int System_Station_ID) { W_Course model = Orm.Single <W_Course>(x => x.System_Station_ID == System_Station_ID && x.ID == Model.ID); if (model == null) { throw new ApiException("您要操作的数据不存在"); } if (Model.Valid == 0) { int count = SqlMapper.QueryForObject <int>("GetCourseOrderCount", new { ID = Model.ID }); if (count > 0) { throw new ApiException("该课程已被网校学生购买无法禁用!"); } } model.Valid = Model.Valid; if (Orm.Update(model) <= 0) { throw new ApiException("修改失败"); } return(true); }
/// <summary> /// 查询网课是否存在 /// </summary> /// <param name="Model"></param> /// <returns></returns> public int GetExsitWebCourse(W_Course Model, int System_Station_ID) { return(SqlMapper.QueryForObject <int>("GetExsitWebCourse", new { Name = Model.Name, System_Station_ID = System_Station_ID, ID = Model.ID })); }