public ActionResult DeleteCourse(CoursesDeleteVM model)
        {
            Course course = unitOfWork.CourseRepository.GetById(model.Id);

            if (course.Students.Count > 0)
            {
                TempData.FlashMessage("You cannot delete course with students in it!", null, FlashMessageTypeEnum.Red);
                model.Name = course.Name;
                model.CourseCode = course.Code;
                return View(model);
            }

            List<CoursesSubjects> css = unitOfWork.CoursesSubjectsRepository.GetByCourseId(course.Id, true);

            css.ForEach(x => x.Teachers.Clear());
            course.CoursesSubjects.Clear();
            course.Students.Clear();

            unitOfWork.CoursesSubjectsRepository.UpdateTable(course, new List<Subject>());

            unitOfWork.CourseRepository.Delete(course.Id);
            unitOfWork.Save();

            TempData.FlashMessage("Course Deleted");
            return RedirectToAction("ManageCourses", "Admin");
        }
        public ActionResult DeleteCourse(int? id)
        {
            if (!id.HasValue)
            {
                return RedirectToAction("ManageCourses", "Admin");
            }

            Course course = unitOfWork.CourseRepository.GetById(id.Value);

            if (course == null)
            {
                return RedirectToAction("ManageCourses", "Admin");
            }

            CoursesDeleteVM model = new CoursesDeleteVM();
            model.Id = course.Id;
            model.Name = course.Name;
            model.CourseCode = course.Code;

            return View(model);
        }