public async Task <IActionResult> DeleteBook(int id) { var book = await _repo.GetBook(id); if (book == null) { return(Unauthorized()); } foreach (var photo in book.Photos) { if (photo.PublicId != null) { var deleteParams = new DeletionParams(photo.PublicId); _cloudinaryConfig.Cloudinary.Destroy(deleteParams); } } _repo.Delete(book); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to delete the book")); }
public ActionResult confirmDelete(int id) { try { bookRepo.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult ConfirmDelete(int id) { try { authorRepository.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Delete(int id, IFormCollection collection) { try { authorRepository.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult Delete(int id, Author author) { try { authorRepo.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <IActionResult> DetelePhoto(int bookId, int id) { var book = await _repo.GetBook(bookId); if (!book.Photos.Any(p => p.Id == id)) { return(Unauthorized()); } var photoFromRepo = await _repo.GetPhoto(id); if (photoFromRepo.IsMain) { return(BadRequest("You can not delete the book main photo")); } if (photoFromRepo.PublicId != null) { var deleteParams = new DeletionParams(photoFromRepo.PublicId); var result = _cloudinaryConfig.Cloudinary.Destroy(deleteParams); if (result.Result == "ok") { _repo.Delete(photoFromRepo); } } if (photoFromRepo.PublicId == null) { _repo.Delete(photoFromRepo); } if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to delete the photo")); }
public ActionResult Delete(int id, Author author) { try { // TODO: Add delete logic here authorRepository.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult ConfirmDelete(int id) { try { // TODO: Add delete logic here bookRepository.Delete(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }