public ActionResult DeletePost(int ID) { // check the ticket ID supplied if (ID != 0) { TicketHelper ticketHelper = new TicketHelper(c_repository); // retrieve the ticket to delete Ticket ticketToDelete = ticketHelper.RetrieveTicket(ID); if (ticketToDelete != null) { // try the Ticket delete if (ticketHelper.DoRemoveTicket(ticketToDelete)) { // ticket was deleted so add message to TempData this.TempData["Success"] = "Ticket deleted succesfully."; // redirect to tickets list view return(RedirectToAction("Index")); } else { // ticket was not deleted so add message to TempData this.TempData["Failure"] = "Ticket was not able to be deleted at this time. Please try again later."; // redirect to tickets list view return(RedirectToAction("Index")); } } else { return(new HttpNotFoundResult("The ticket could not be found, and therefore could not be deleted.")); } } else { // no ticket ID supplied, return bad request error return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "No ticket ID was supplied.")); } }