public void SetCourseSort(HttpContext context) { try { List <CourseRel> CourseRel_List = Constant.CourseRel_List; HttpRequest request = context.Request; string Course_Nos = RequestHelper.string_transfer(request, "Course_No"); string Course_Typeid = RequestHelper.string_transfer(request, "CourseTypeId"); int StudySection_Id = RequestHelper.int_transfer(request, "StudySection_Id"); foreach (string Course_No in Course_Nos.Split(',')) { var CourseRel_ = CourseRel_List.Where(i => i.Course_Id == Course_No && i.StudySection_Id == StudySection_Id).FirstOrDefault(); if (CourseRel_ != null) { CourseRel_.CourseType_Id = Course_Typeid; jsonModel = Constant.CourseRelService.Update(CourseRel_); } else { CourseRel courseRef = new CourseRel() { Course_Id = Course_No, CourseType_Id = Course_Typeid, StudySection_Id = StudySection_Id, CreateTime = DateTime.Now, CreateUID = "", EditTime = DateTime.Now, EditUID = "", IsDelete = (int)IsDelete.No_Delete, }; jsonModel = Constant.CourseRelService.Add(courseRef); if (jsonModel.errNum == 0) { courseRef.Id = Convert.ToInt32(jsonModel.retData); Constant.CourseRel_List.Add(courseRef); } } } } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }
public void EditCourse(HttpContext context) { int intSuccess = (int)errNum.Success; HttpRequest request = context.Request; string Ids = RequestHelper.string_transfer(request, "Ids"); int Enable = RequestHelper.int_transfer(request, "Enable"); int CourseTypeId = RequestHelper.int_transfer(request, "CourseTypeId"); int Operation = RequestHelper.int_transfer(request, "Operation"); try { //课程变更【启用禁用】 if (!string.IsNullOrEmpty(Ids)) { int[] Ids_ints = Split_Hepler.str_to_ints(Ids); foreach (var id in Ids_ints) { //设置课程启用禁用 if (Operation == 1) { jsonModel = Constant.CourseService.GetEntityById(id); if (jsonModel.errNum == 0) { Course s_course = jsonModel.retData as Course; s_course.IsEnable = (byte)Enable; JsonModel model = Constant.CourseService.Update(s_course); if (jsonModel.errNum == 0) { Course course = Constant.Course_List.FirstOrDefault(cour => cour.Id == id); course.IsEnable = s_course.IsEnable; } } } if (Operation == 2) { CourseRel courseRef = Constant.CourseRel_List.FirstOrDefault(re => re.Course_Id == Convert.ToString(id)); if (courseRef != null && CourseTypeId != 0) { CourseRel courseRef_Clone = Constant.Clone <CourseRel>(courseRef); courseRef_Clone.CourseType_Id = Convert.ToString(CourseTypeId); JsonModel model = Constant.CourseRelService.Update(courseRef_Clone); } } } jsonModel = JsonModel.get_jsonmodel(intSuccess, "success", "0"); } else { jsonModel = JsonModel.get_jsonmodel((int)errNum.Failed, "failed", "数据出现异常"); } } catch (Exception ex) { LogHelper.Error(ex); } finally { //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】 context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}"); } }