public ActionResult DeleteBand(Guid bandId) { var bandFromRepo = _repository.GetBand(bandId); if (bandFromRepo == null) { return(NotFound()); } _repository.DeleteBand(bandFromRepo); _repository.Save(); return(NoContent()); }
public async Task <ActionResult> DeleteBand(Guid bandId) { var bandFromRepo = await _bandAlbumRepository.GetBand(bandId); if (bandFromRepo == null) { return(NotFound()); } _bandAlbumRepository.DeleteBand(bandFromRepo); // The Children (Albums) will be delted as well await _bandAlbumRepository.Save(); return(Ok(_mapper.Map <BandDto>(bandFromRepo))); }
public ActionResult DeleteBand(Guid bandId) { Band band = _bandAlbumRepository.GetBand(bandId); if (band == null) { return(NotFound()); } _bandAlbumRepository.DeleteBand(band); _bandAlbumRepository.Save(); return(NoContent()); }
public IActionResult DeleteBand(Guid bandId) { var bandToDelete = _bandAlbumRepository.GetBand(bandId); if (bandToDelete == null) { return(StatusCode(StatusCodes.Status400BadRequest)); } _bandAlbumRepository.DeleteBand(bandToDelete); _bandAlbumRepository.Save(); return(StatusCode(StatusCodes.Status204NoContent)); }
public ActionResult DeleteBand(Guid bandID) { var bandFromRepo = _bandAlbumRepository.GetBand(bandID); if (bandFromRepo is null) { return(NotFound()); } _bandAlbumRepository.DeleteBand(bandFromRepo); _bandAlbumRepository.Save(); return(NoContent()); }
public ActionResult DeleteBand(Guid bandId) { if (bandId == null) { throw new ArgumentNullException(nameof(bandId)); } var band = _repository.GetBand(bandId); if (band == null) { return(NotFound()); } _repository.DeleteBand(bandId); _repository.Save(); return(NoContent()); }
public ActionResult DeleteBand(Guid bandId) { if (!_bandAlbumRepository.BandExists(bandId)) { return(NotFound()); } // Look for all related albums IEnumerable <Album> albums = _bandAlbumRepository.GetAlbums(bandId); // Delete all related albums _bandAlbumRepository.DeleteAlbums(albums); // Look for band var band = _bandAlbumRepository.GetBand(bandId); // Delete band _bandAlbumRepository.DeleteBand(band); _bandAlbumRepository.Save(); return(NoContent()); }