/// <summary> /// 删除教室 /// </summary> /// <returns></returns> public bool DeleteClassRoom(ClassRoomModel Model, int System_Station_ID) { W_ClassRoom ClassRoomModel = Orm.Single <W_ClassRoom>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID); if (ClassRoomModel == null) { throw new ApiException("操作失败,您要删除的教室不存在"); } if (Orm.Delete(ClassRoomModel) <= 0) { throw new ApiException("删除失败,请重试"); } return(true); }
/// <summary> /// 启用禁用教室 /// </summary> /// <returns></returns> public dynamic UpdateClassRoomValid(ClassRoomModel Model, int System_Station_ID) { W_ClassRoom ClassRoomModel = Orm.Single <W_ClassRoom>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID); if (ClassRoomModel == null) { throw new ApiException("操作失败,请稍后再试"); } ClassRoomModel.Valid = Model.Valid; if (Orm.Update(ClassRoomModel) <= 0) { throw new ApiException("修改失败"); } return(true); }
/// <summary> ///添加修改校区教室 /// </summary> public bool SaveClassRoom(W_ClassRoom Model, int System_Station_ID, int AccountID) { if (Model.ID > 0)//修改 { ///判断数据是否存在 W_ClassRoom model = Orm.Single <W_ClassRoom>(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; 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); } } }
/// <summary> /// 启用禁用校区 /// </summary> /// <returns></returns> public dynamic UpdateValid(CampusModel Model, int System_Station_ID) { W_Campus campusmodel = Orm.Single <W_Campus>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID); if (campusmodel == null) { throw new ApiException("操作失败,请稍后再试"); } if (Model.Valid == 0) { W_ClassRoom roommodel = Orm.Single <W_ClassRoom>(x => x.CampusID == Model.ID && x.System_Station_ID == System_Station_ID); if (roommodel != null) { throw new ApiException("该校区下面存在教室,不能禁用"); } } campusmodel.Valid = Model.Valid; if (Orm.Update(campusmodel) <= 0) { throw new ApiException("修改失败"); } return(true); }
/// <summary> /// 删除校区 /// </summary> /// <returns></returns> public bool DeleteCampus(CampusModel Model, int System_Station_ID) { W_Campus campusmodel = Orm.Single <W_Campus>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID); if (campusmodel == null) { throw new ApiException("操作失败,未找到要操作的数据,请刷新再试"); } if (campusmodel.Valid == 1) { throw new ApiException("启用状态中,不能删除"); } W_ClassRoom roommodel = Orm.Single <W_ClassRoom>(x => x.CampusID == Model.ID && x.System_Station_ID == System_Station_ID); if (roommodel != null) { throw new ApiException("该校区下面存在教室,不能删除"); } if (Orm.Delete(campusmodel) <= 0) { throw new ApiException("删除失败,请重试"); } return(true); }
public dynamic SaveClassRoom(W_ClassRoom Model) { return(Success(mapper.SaveClassRoom(Model, this.System_Station_ID, this.AccountID))); }