public async Task <ActionResult> Delete(int id) { CinemaDomainModel deletedCinema; try { deletedCinema = await _cinemaService.DeleteCinema(id); } catch (DbUpdateException e) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = e.InnerException.Message ?? e.Message, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } if (deletedCinema == null) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = Messages.MOVIE_DOES_NOT_EXIST, StatusCode = System.Net.HttpStatusCode.InternalServerError }; return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, errorResponse)); } return(Accepted("cinemas//" + deletedCinema.Id, deletedCinema)); }
public IActionResult DeleteCinema(int cinemaId) { if (!_сinemaService.CheckCinemaExists(cinemaId)) { return(NotFound(new Response(ErrorOfCinemaNonexistence))); } _сinemaService.DeleteCinema(cinemaId); return(Ok(new Response())); }
public async Task <IActionResult> DeleteConfirmed(int id) { var cinemaDeletd = await _cinemaService.DeleteCinema(id); if (cinemaDeletd) { var listOfAllCinemas = _cinemaService.GetAllCinemas(); return(View("Index", listOfAllCinemas.ToList()).WithSuccess("Info!", "Cinema was deleted successfully!")); } else { return(BadRequest()); } }
public async Task <IActionResult> DeleteCinema([FromRoute] int id) { if (id <= 0) { return(BadRequest()); } try { await Task.Run(() => _cinemaService.DeleteCinema(id)); } catch (ArgumentNullException) { return(BadRequest()); } return(Ok()); }
public async Task <ActionResult> Delete(int id) { CreateCinemaResultModel deletedCinema; try { deletedCinema = await _cinemaService.DeleteCinema(id); } catch (DbUpdateException e) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = e.InnerException.Message ?? e.Message, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } if (deletedCinema.Cinema == null) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = Messages.CINEMA_NOT_FOUND, StatusCode = System.Net.HttpStatusCode.InternalServerError }; return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, errorResponse)); } if (!deletedCinema.IsSuccessful) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = Messages.AUDITORIUM_DELETION_ERROR, StatusCode = System.Net.HttpStatusCode.InternalServerError }; return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, errorResponse)); } return(Accepted("cinemas//" + deletedCinema.Cinema.Id, deletedCinema)); }