public async Task <ActionResult> DeleteAutorAsync(int id) { var autor = await autorRepository.GetAsync(id); if (autor == null) { return(NotFound()); } if (!await autorRepository.DeleteAsync(autor)) { ModelState.AddModelError("Response", $"Ha ocurrido un error al intentar eliminar el libro {autor.Nombre}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public async Task <IActionResult> Delete(int id) { var autor = await autorRepository.GetAsync(configuration["APIAuthor:BaseUrl"], id); if (autor == null) { return(NotFound()); } var modelError = await autorRepository.DeleteAsync(configuration["APIAuthor:BaseUrl"], autor.IdAutor); if (modelError.Response.Errors.Count > 0) { autor.Errors = new List <Errors>(); foreach (var item in modelError.Response.Errors) { autor.Errors.Add(item); } return(View(autor)); } return(RedirectToAction(nameof(Index))); }