/// <summary> /// 按courseId删除课程. /// @author ZhouZhongjun /// </summary> /// <param name="courseId">课程Id</param> /// <seealso cref="M:Xmu.Crms.Shared.Service.ISeminarService.DeleteSeminarByCourseId(System.Int64)"/> /// <seealso cref="M:Xmu.Crms.Shared.Service.IClassService.DeleteClassByCourseId(System.Int64)"/> /// <exception cref="T:System.ArgumentException">courseId格式错误时抛出</exception> /// <exception cref="T:Xmu.Crms.Shared.Exceptions.CourseNotFoundException">未找到课程</exception> public void DeleteCourseByCourseId(long courseId) { if (courseId <= 0) { throw new ArgumentException("格式错误!"); } var course = _db.Course.Where(c => c.Id == courseId).SingleOrDefault(); if (course == null) { throw new CourseNotFoundException(); } //删除course下的所有班级 _classService.DeleteClassByCourseId(courseId); //删除course下的所有Seminar _seminarService.DeleteSeminarByCourseId(courseId); //删除course下的所有课程 _db.Course.Remove(course); _db.SaveChanges(); }
public void DeleteCourseByCourseId(long courseId) { try { if (courseId < 0) { throw new ArgumentException(); } //删除course下的class _iClassService.DeleteClassByCourseId(courseId); //删除course下的seminar _iSeminarService.DeleteSeminarByCourseId(courseId); //删除course _iCourseDao.DeleteCourseByCourseId(courseId); } catch (ClassNotFoundException) { //删除course下的seminar _iSeminarService.DeleteSeminarByCourseId(courseId); //删除course _iCourseDao.DeleteCourseByCourseId(courseId);; } catch (CourseNotFoundException cre) { throw cre; } }
public void DeleteCourseByCourseId(long courseId) { try { if (courseId < 0) { throw new ArgumentException(); } //删除course下的class _iClassService.DeleteClassByCourseId(courseId); //删除course下的seminar //_iSeminarService.DeleteSeminarByCourseId(courseId); //删除course _iCourseDao.DeleteCourseByCourseId(courseId); } catch { throw; } }