public ActionResult Delete(int id, IFormCollection collection) { try { _deleteCarCommand.Execute(id); return(RedirectToAction(nameof(Index))); } catch (EntityNotFoundException ex) { TempData["error"] = ex.Message; return(View()); } }
public ActionResult Delete(int id) { try { _deleteCar.Execute(id); return(StatusCode(204)); } catch (EntityNotFoundException e) { return(NotFound(e.Message)); } catch (Exception e) { Console.WriteLine(e.Message); return(StatusCode(500)); } }
public IActionResult Delete( [FromServices] IDeleteCarCommand command, int id) => command.Execute(id);