public Lecturer DeletLecturerById(int id) { var lecturer = _lecturerRepository.Records.Where(x => x.Id == id).FirstOrDefault(); if (lecturer != null) { _lecturerRepository.Delete(lecturer); } return(lecturer); }
public Lecturer DeleteLecturerById(int id) { var lecturer = _lecturerRepository.GetById(id); if (lecturer != null) { _lecturerRepository.Delete(lecturer); } return(lecturer); }
public bool Delete(int id) { if (_lecturerRepository.Records.Any(x => x.Id == id)) { var courses = _lecturerCourseRepository.Records.Where(x => x.CourseId == id).ToList(); foreach (var course in courses) { _lecturerCourseRepository.Delete(course); } _lecturerRepository.Delete(_lecturerRepository.GetById(id)); return(true); } else { return(false); } }
public string Delete(Lecturer lecture) { if (_lectureRepository.Records.Any(s => s.Id == lecture.Id)) { if (_lectureCourseRepository.Records.Any(sc => sc.LecturerId == lecture.Id)) { var lecturecourses = _lectureCourseRepository.Records.Where(sc => sc.LecturerId == lecture.Id); _lectureCourseRepository.Records.RemoveRange(lecturecourses); _lectureCourseRepository.SaveChanges(); } _lectureRepository.Delete(lecture); return("successfully deleted"); } else { return("No such lecture"); } }
public bool Delete(int id) { _lecturerRepository.Delete(_lecturerRepository.GetById(id)); return(true); }
public void DeleteById(int id) { var course = _lectureRepository.GetById(id); _lectureRepository.Delete(course); }