// // GET: /Default1/Details/5 public ActionResult Details(int id) { var product = new Product { Id = 1, Name="Comb", Price = 344.22m, OnSale = true }; return View(product); }
public ActionResult Create(Product productToCreate) { if (productToCreate.Price < 0) { ModelState.AddModelError("Price", "Price must be greater than zero"); } if (ModelState.IsValid) { // stick the product in the db return RedirectToAction("Index"); } return View(productToCreate); }