public ActionResult Delete(int?id) { if (id == null) { return(View("Error")); } var product = _repo.getProductById(id); if (product == null) { return(View("Error")); } _repo.DeleteProduct(product.ProductId); return(RedirectToAction("Index")); }