//[HttpPost] //public ActionResult Delete(int id) //{ // Product deletedProduct = respository.DeleteProduct(id); // if (deletedProduct != null) // { // TempData["message"] = string.Format("{0} was deleted", // deletedProduct.Name); // } // return RedirectToAction("Index"); //} public ActionResult Delete(int id) { Product product = respository.DeleteProduct(id); if (product != null) { TempData["message"] = string.Format("{0} was delted", product.Name); } return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(int productId) { Product deletedProduct = repository.DeleteProduct(productId); if (deletedProduct != null) { TempData["message"] = string.Format("{0} 已经被删除了", deletedProduct.Name); } return(RedirectToAction("Index", "Admin", new { page = 1 })); }