public ActionResult StronglyTypedMenu() { var menu = new Menu { Id = 1, Text = "Schweinsbraten mit Knödel und Sauerkraut", Price = 6.9, Date = new DateTime(2013, 10, 5), Category = "Main" }; return View(menu); }
public ActionResult CreateMenu(Menu m) { if (ModelState.IsValid) { ViewBag.Info = string.Format( "Menu created: {0}, Price: {1}, Category {2}", m.Text, m.Price, m.Category); } else { ViewBag.Info = "not valid"; } return View("Index"); }
public ActionResult SubmitData(Menu m) { if (ModelState.IsValid) { m.Date = DateTime.Now; MenuDB context = new MenuDB(); context.Menus.Add(m); context.SaveChanges(); ViewBag.Info = string.Format( "Menu created: {0}, Price: {1}, Category {2}", m.Text, m.Price, m.Category); } else { ViewBag.Info = "not valid"; } return View("Index",db.Menus.ToList()); }