public ActionResult Create([Bind(Include = "ProducerId,Name")] Producer producer) { if (ModelState.IsValid) { fe.Producers.Add(producer); fe.SaveChanges(); return(RedirectToAction("Index")); } return(View(producer)); }
public ActionResult Create([Bind(Include = "CategoryId,Name,Description")] Category category) { if (ModelState.IsValid) { fe.Categories.Add(category); fe.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "ItemId,CategoryId,ProduceId,Title,Price,ItemArtUrl")] Item item) { if (ModelState.IsValid) { fe.Items.Add(item); fe.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(fe.Categories, "CategoryId", "Name", item.CategoryId); ViewBag.ProduceId = new SelectList(fe.Producers, "ProducerId", "Name", item.ProduceId); return(View(item)); }
public ActionResult Register(User user) { if (ModelState.IsValid) { using (FourSeasonsEntities fe = new FourSeasonsEntities()) { fe.Users.Add(user); fe.SaveChanges(); } ModelState.Clear(); ViewBag.Message = user.FirstName + " " + user.LastName + " succesfully registered."; } return(View()); }