public IActionResult DeleteAuthor(Guid authorId)
 {
     if (_courseLibraryRepository.GetAuthor(authorId) != null)
     {
         _courseLibraryRepository.DeleteAuthor(_courseLibraryRepository.GetAuthor(authorId));
         _courseLibraryRepository.Save();
         return(Ok());
     }
     return(NotFound());
 }
Ejemplo n.º 2
0
        public IActionResult Delete(Guid authorId)
        {
            var author = _repository.GetAuthor(authorId);

            if (author == null)
            {
                return(NotFound());
            }
            _repository.DeleteAuthor(author);
            _repository.Save();
            return(NoContent());
        }
Ejemplo n.º 3
0
        public bool DeleteAuthor(Guid authorId)
        {
            var x = _repo.GetAuthor(authorId);

            if (x == null)
            {
                return(false);
            }
            _repo.DeleteAuthor(x);
            _repo.Save();
            return(true);
        }
Ejemplo n.º 4
0
        public ActionResult DeleteAuthor(Guid authorId)
        {
            if (!_CourseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound());
            }
            var AuthorToDelete = _CourseLibraryRepository.GetAuthor(authorId);

            _CourseLibraryRepository.DeleteAuthor(AuthorToDelete);
            _CourseLibraryRepository.Save();
            return(NoContent());
        }
Ejemplo n.º 5
0
        public ActionResult DeleteAuthor(Guid authorId)
        {
            var authorFromRepo = _courseLibraryRepository.GetAuthor(authorId);

            if (authorFromRepo == null)
            {
                return(NotFound());
            }
            _courseLibraryRepository.DeleteAuthor(authorFromRepo);
            _courseLibraryRepository.Save();
            return(NoContent());
        }
Ejemplo n.º 6
0
        public ActionResult <AuthorDto> DeleteAuthor(Guid authorId)
        {
            var authorEntity = _courseLibraryRepository.GetAuthor(authorId);

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

            _courseLibraryRepository.DeleteAuthor(authorEntity);
            _courseLibraryRepository.Save();
            return(NoContent());
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Delete(Guid authorId)
        {
            var author = await mRepository.GetAuthorAsync(authorId);

            if (author == null)
            {
                return(NotFound());
            }
            mRepository.DeleteAuthor(author);
            await mRepository.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 8
0
        public ActionResult DeleteAuthor(string authorId)
        {
            var authorFromRepo = _courseLibraryRepository.GetAuthor(ObjectId.Parse(authorId));

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

            _courseLibraryRepository.DeleteAuthor(ObjectId.Parse(authorId));

            return(NoContent());
        }
Ejemplo n.º 9
0
        public ActionResult DeleteAuthor(Guid authorId)
        {
            var authorToDelete = repository.GetAuthor(authorId);

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

            repository.DeleteAuthor(authorToDelete);
            repository.Save();

            return(NoContent());
        }
        public async Task <ActionResult> DeleteAuthor(Guid authorId)
        {
            var authorRepo = await _courseLibaryService.GetAuthor(authorId);

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

            _courseLibaryService.DeleteAuthor(authorRepo);
            await _courseLibaryService.Save();

            return(NoContent());
        }
Ejemplo n.º 11
0
        public ActionResult DeleteAuthor(Guid authorId)
        {
            var authorFromRepo = _courseLibraryRepository.GetAuthor(authorId);

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

            _courseLibraryRepository.DeleteAuthor(authorFromRepo);
            _courseLibraryRepository.Save();  // Cascading deletes are on by default with EFCore

            return(NoContent());
        }
        public async Task <ActionResult> DeleteAuthor(Guid authorId)
        {
            var authorFromRepo = await _courseLibraryRepository.GetAuthorAsync(authorId);

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

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

            return(NoContent());
        }
        public ActionResult DeleteAuthor(Guid authorId)
        {
            var authorFromRepo = _clRepo.GetAuthor(authorId);

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

            _clRepo.DeleteAuthor(authorFromRepo);

            _clRepo.Save();

            return(NoContent());
        }
        public ActionResult DeleteAuthor(Guid authorId)
        {
            var authorFromRepo = repository.GetAuthor(authorId);

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

            // CascadeOnDelete is on by default; when we delete a author, his/her courses
            // will be deleted as will
            repository.DeleteAuthor(authorFromRepo);
            repository.Save();

            return(NoContent());
        }
Ejemplo n.º 15
0
        public async Task <ActionResult> DeleteAuthor(Guid authorId)
        {
            var authorFromRepo = await _repository.GetAuthor(authorId);

            if (authorFromRepo == null)
            {
                return(NotFound());
            }
            _repository.DeleteAuthor(authorFromRepo);
            if (!await _repository.Save())
            {
                return(BadRequest("Error Happens when saving in Data Base"));
            }

            return(NoContent());
        }
        public ActionResult DeleteAuthor(Guid authorId)
        {
            if (authorId == null)
            {
                return(NotFound());
            }

            var author = _courseLibrary.GetAuthor(authorId);

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

            _courseLibrary.DeleteAuthor(author);
            _courseLibrary.Save();

            return(NoContent());
        }
Ejemplo n.º 17
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.º 18
0
        public ActionResult DeleteAuthor(Guid authorId)
        {
            var authorToDelete = _courselibraryRepository.GetAuthor(authorId);

            if (authorToDelete == null)
            {
                return(NotFound());
            }
            //No need below, when parent is deleted then the child will be deleted too
            //var coursesForAuthor = _courselibraryRepository.GetCourses(authorId);
            //if(coursesForAuthor.Count() > 0)
            //{
            //    foreach(var courseForAuthor in coursesForAuthor)
            //    {
            //        _courselibraryRepository.DeleteCourse(courseForAuthor);
            //    }
            //}
            _courselibraryRepository.DeleteAuthor(authorToDelete);
            _courselibraryRepository.Save();
            return(NoContent());
        }
Ejemplo n.º 19
0
        public ActionResult DeleteAuthor(Guid authorId)
        {
            if (!_courseLibraryRepository.AuthorExists(authorId))
            {
                return(NotFound("Author does not exist"));
            }

            var auth = _courseLibraryRepository.GetAuthor(authorId);

            if (auth == null)
            {
                return(NotFound("Author cannot be found"));
            }
            _courseLibraryRepository.DeleteAuthor(auth);
            var result = _courseLibraryRepository.Save();

            if (result)
            {
                return(Ok("Author has been deleted Successfully"));
            }

            return(BadRequest("Unable to delete author"));
        }