private void Delete() { int courseId = int.Parse(Helper.GetParameterFromRequest("courseId")); //检查课程是否已经被分配到专业 IEntityRepository Repo = factory.Create("majorcourse"); IMajorCourseRepository majorCourseRepo = Repo as IMajorCourseRepository; int count = majorCourseRepo.CourseAssignToMajorCount(courseId); if (count > 0) { Helper.ResponseError(607); return; } IEntityRepository CourseRepo = factory.Create("course"); int result = CourseRepo.Delete(courseId); if (result == 1) { Helper.Response("1"); } else { Helper.ResponseError(CourseRepo.ErrorMessage); } }
private void Delete() { int majorId = int.Parse(Helper.GetParameterFromRequest("majorId")); //判断专业下是否有课程 IEntityRepository Repo = factory.Create("majorcourse"); IMajorCourseRepository majorCourseRepo = Repo as IMajorCourseRepository; int count = majorCourseRepo.CourseInMajorCount(majorId); if (count > 0) { Helper.ResponseError(607); return; } Repo = factory.Create("major"); int result = Repo.Delete(majorId); if (result == 1) { Helper.Response("1"); } else { Helper.ResponseError(Repo.ErrorMessage); } }
private void GetList() { IEntityRepository Repo = factory.Create("majorcourse"); IMajorCourseRepository MajorCourseRepo = Repo as IMajorCourseRepository; int majorId = int.Parse(Helper.GetParameterFromRequest("majorId")); Entities entities = MajorCourseRepo.GetList(majorId); if (string.IsNullOrEmpty(Repo.ErrorMessage)) { Helper.Response(entities.Serialize()); } else { Helper.ResponseError(Repo.ErrorMessage); } }
private void Delete() { IEntityRepository Repo = factory.Create("majorcourse"); IMajorCourseRepository MajorCourseRepository = Repo as IMajorCourseRepository; int majorId = int.Parse(Helper.GetParameterFromRequest("majorId")); int courseId = int.Parse(Helper.GetParameterFromRequest("courseId")); int result = MajorCourseRepository.Delete(majorId, courseId); if (result == 1) { Helper.Response("1"); } else { Helper.ResponseError(Repo.ErrorMessage); } }