Ejemplo n.º 1
0
        public IActionResult Delete(Guid authorId, Guid courseId)
        {
            var course = _repository.GetCourse(authorId, courseId);

            if (course == null)
            {
                return(NotFound());
            }
            _repository.DeleteCourse(course);
            _repository.Save();
            return(NoContent());
        }
Ejemplo n.º 2
0
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            var courseForAuthorFromRepo = _courseLibraryRepository.GetCourse(authorId, courseId);

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

            _courseLibraryRepository.DeleteCourse(courseForAuthorFromRepo);
            _courseLibraryRepository.Save();

            return(NoContent());
        }
Ejemplo n.º 3
0
        public IActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId, CourseForUpdateDto courseForUpdateDto)
        {
            if (!_courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }
            var courseEntity = _courseLibraryRepository.GetCourse(authorId, courseId);

            if (courseEntity == null)
            {
                return(NotFound());
            }
            _courseLibraryRepository.DeleteCourse(courseEntity);
            _courseLibraryRepository.Save();
            return(NoContent());
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> DeleteCourse(Guid authorId, Guid courseId)
        {
            if (!await mRepository.AuthorExistsAsync(authorId))
            {
                return(NotFound());
            }
            var courseToDel = await mRepository.GetCourseAsync(authorId, courseId);

            if (courseToDel == null)
            {
                return(NotFound());
            }
            mRepository.DeleteCourse(courseToDel);
            await mRepository.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!await _courseLibraryRepository.AuthorExistsAsync(authorId))
            {
                return(NotFound());
            }

            var course = await _courseLibraryRepository.GetCourseAsync(authorId, courseId);

            if (course == null)
            {
                return(NotFound());
            }
            _courseLibraryRepository.DeleteCourse(course);
            await _courseLibraryRepository.SaveAsync();

            return(NoContent());
        }
        public ActionResult Delete(Guid authorId, Guid CourseId)
        {
            if (!_courseLibrary.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var course = _courseLibrary.GetCourse(authorId, CourseId);

            if (course == null)
            {
                return(NotFound());
            }
            _courseLibrary.DeleteCourse(course);
            _courseLibrary.Save();

            return(NoContent());
        }
Ejemplo n.º 7
0
        public bool DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_repo.AuthorExists(authorId))
            {
                return(false);
            }

            var courseToDelete = _repo.GetCourse(authorId, courseId);

            if (courseToDelete == null)
            {
                return(false);
            }

            _repo.DeleteCourse(courseToDelete);
            _repo.Save();
            return(true);
        }
Ejemplo n.º 8
0
        public ActionResult DeleteCourseFromAuthor(Guid authorId, Guid courseId)
        {
            if (!courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseAuthorFromRepo = courseLibraryRepository.GetCourse(authorId, courseId);

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

            courseLibraryRepository.DeleteCourse(courseAuthorFromRepo);
            courseLibraryRepository.Save();
            return(NoContent());
        }
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_courseLibaryService.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseForAuthorFromEntity = _courseLibaryService.GetCourse(authorId, courseId);

            if (courseForAuthorFromEntity == null)
            {
                return(NotFound());
            }
            _courseLibaryService.DeleteCourse(courseForAuthorFromEntity);
            _courseLibaryService.Save();

            return(NoContent());
        }
Ejemplo n.º 10
0
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_courselibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }
            var courseToBeDelete = _courselibraryRepository.GetCourse(authorId, courseId);

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

            _courselibraryRepository.DeleteCourse(courseToBeDelete);
            _courselibraryRepository.Save();

            return(NoContent());
        }
Ejemplo n.º 11
0
        public IActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_repository.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseFromRepo = _repository.GetCourse(authorId, courseId);

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

            _repository.DeleteCourse(courseFromRepo);
            _repository.Save();

            return(NoContent());
        }
Ejemplo n.º 12
0
        public ActionResult DeleteCourseFromAuthor(Guid authorId, Guid courseId)
        {
            //Check if author exists
            if (!_courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }
            var authorCourse = _courseLibraryRepository.GetCourse(authorId, courseId);

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

            _courseLibraryRepository.DeleteCourse(authorCourse);
            _courseLibraryRepository.Save();

            return(NoContent());
        }
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_context.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseForAuthorFromRepo = _context.GetCourse(authorId, courseId);

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

            _context.DeleteCourse(courseForAuthorFromRepo);
            _context.Save();

            return(NoContent());
        }
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!courseRepo.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseToDelete = courseRepo.GetCourse(authorId, courseId);

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

            courseRepo.DeleteCourse(courseToDelete);
            courseRepo.Save();

            return(NoContent());
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!await _repository.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseFromRepo = await _repository.GetCourse(authorId, courseId);

            if (courseFromRepo == null)
            {
                return(NotFound());
            }
            _repository.DeleteCourse(courseFromRepo);
            if (!await _repository.Save())
            {
                return(BadRequest("Error Happens when saving in Data Base"));
            }
            return(NoContent());
        }
Ejemplo n.º 16
0
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseForAuthorFromRepo =
                _courseLibraryRepository.GetCourse(authorId, courseId);

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

            _courseLibraryRepository.DeleteCourse(courseForAuthorFromRepo);
            _courseLibraryRepository.Save();

            return(NoContent());  // no response body with DELETE.
        }
Ejemplo n.º 17
0
        public ActionResult DeleteCourseForAuthor(
            [FromRoute] Guid authorId,
            [FromRoute] Guid courseId)
        {
            if (!AuthorExists(authorId))
            {
                return(NotFound());
            }

            Course courseFromRepo = _courseLibraryRepository.GetCourse(authorId, courseId);

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

            _courseLibraryRepository.DeleteCourse(courseFromRepo);
            _courseLibraryRepository.Save();

            return(NoContent());
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> DeleteAuthor(Guid authorId)
        {
            var authorEntity = await _courseLibraryRepository.GetAuthorAsync(authorId);

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

            var courses = await _courseLibraryRepository.GetCoursesAsync(authorId); // We delete all author's courses.

            courses.ToList().ForEach(c =>
            {
                _courseLibraryRepository.DeleteCourse(c);
            });

            _courseLibraryRepository.DeleteAuthor(authorEntity);
            await _courseLibraryRepository.SaveAsync();

            return(NoContent());
        }
Ejemplo n.º 19
0
        public ActionResult DeleteCourse(Guid authorId, Guid courseId)
        {
            if (!_courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound("Unable to find author"));
            }

            var collect = _courseLibraryRepository
                          .GetCourse(authorId, courseId);

            if (collect == null)
            {
                return(NotFound("The course cannot be found"));
            }
            _courseLibraryRepository.DeleteCourse(collect);
            var result = _courseLibraryRepository.Save();

            if (result)
            {
                return(Ok("Delete Successful"));
            }

            return(BadRequest("Unable to delete course"));
        }
Ejemplo n.º 20
0
        public ActionResult DeleteCourseForAuthor(Guid authorId, Guid courseId)
        {
            if (!_courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }

            var courseForAuthorFromRepo = _courseLibraryRepository.GetCourse(authorId, courseId);

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

            _courseLibraryRepository.DeleteCourse(courseForAuthorFromRepo);
            _courseLibraryRepository.Save();

            return(new JsonResult(new
            {
                resposta = "deletado",
                cursoId = courseId,
                autorId = authorId
            }));
        }