public IActionResult DeleteReview(int directorId) { if (!directorRepository.DirectorExists(directorId)) { return(NotFound(404)); } var deleteReview = directorRepository.GetDirector(directorId); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (directorRepository.GetMoviesByDirector(directorId).Count() > 0) { ModelState.AddModelError("", "there are movies associated and thus can't delete"); return(StatusCode(409, ModelState)); } if (!directorRepository.DeleteDirector(deleteReview)) { ModelState.AddModelError("", "Something went wrong,Please try again"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { Director movie = _directorRepository.GetDirectorById(id); _directorRepository.DeleteDirector(id); _directorRepository.Save(); return(RedirectToAction("Index")); }
public async Task DeleteDirector(int DirectorId) { try { await _directorReposity.DeleteDirector(DirectorId); } catch (System.Exception ex) { throw ex; } }
public async Task <ActionResult <DirectorDTO> > DeleteDirector(int id) { var directorResult = await _directorRepository.DeleteDirector(id).ConfigureAwait(false); if (directorResult == null) { return(NotFound()); } return(directorResult); }
public async Task <IActionResult> DeleteDirector(string id) { try { if (!Guid.TryParse(id, out Guid directorId)) { throw new GuidException("Invalid id", this.GetType().Name, "DeleteDirector", "400"); } await _directorRepository.DeleteDirector(id); return(NoContent()); } catch (MovieMindException e) { if (e.MovieMindError.Status.Equals("404")) { return(NotFound(e.MovieMindError)); } else { return(BadRequest(e.MovieMindError)); } } }
public void Delete(int directorId) { _directorRepository.DeleteDirector(directorId); }
public string DeleteDirector(int directorid) { int deletedirector = Task.Run <int>(async() => await DirectorRepository.DeleteDirector(directorid)).Result; return(deletedirector > 0 ? "Successfully deleted Director record" : "Deletion failed"); }