Example #1
0
        public Lecturer DeletLecturerById(int id)
        {
            var lecturer = _lecturerRepository.Records.Where(x => x.Id == id).FirstOrDefault();

            if (lecturer != null)
            {
                _lecturerRepository.Delete(lecturer);
            }
            return(lecturer);
        }
Example #2
0
        public Lecturer DeleteLecturerById(int id)
        {
            var lecturer = _lecturerRepository.GetById(id);

            if (lecturer != null)
            {
                _lecturerRepository.Delete(lecturer);
            }

            return(lecturer);
        }
Example #3
0
 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);
     }
 }
Example #4
0
        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");
            }
        }
Example #5
0
 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);
        }