Esempio n. 1
0
        public async Task <IActionResult> DeleteCourse(int id)
        {
            if (id == null)
            {
                return(BadRequest());
            }


            var data = await Context.Course.SingleOrDefaultAsync(ww => ww.CourseId == id);


            if (data == null)
            {
                return(NotFound());
            }

            var userCourse = await Context.UserCourse.FirstOrDefaultAsync(ww => ww.CourseId == id);

            if (userCourse != null)
            {
                return(BadRequest(new { message = "this Course Is assigned To Some Users .. So you can't delete it" }));
            }

            Db.DeleteCourse(id);
            return(Ok(data));
        }
        public IHttpActionResult DeleteCourse(int id)
        {
            if (!CourseExists(id))
            {
                return(NotFound());
            }

            _repo.DeleteCourse(id);
            _repo.SaveChanges();

            return(Ok());
        }
Esempio n. 3
0
        public ActionResult DeleteCourse(int id)
        {
            var courseModelFromRepo = _repository.GetCourseById(id);

            if (courseModelFromRepo == null)
            {
                return(NotFound());
            }
            _repository.DeleteCourse(courseModelFromRepo);
            _repository.SaveChanges();

            return(NoContent());
        }
Esempio n. 4
0
        public IActionResult OnGet(int courseId)
        {
            Course = _courseRepo.GetCourseById(courseId);
            if (Course == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            _courseRepo.DeleteCourse(courseId);
            _courseRepo.Commit();

            Message = "Course deleted successfully";
            return(RedirectToPage("./AllCourses"));
        }
 public IActionResult Delete(Course model)
 {
     _repository.DeleteCourse(model.Id);
     return(PartialView("_CourseSuccessPartial"));
 }