public ActionResult Create([Bind(Include = "ID,FirstName,LastName")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "OrderID,UserID,TrackingID,City,State,Zip")] Order order) { if (ModelState.IsValid) { db.Orders.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.Users, "ID", "FirstName", order.UserID); return(View(order)); }
public ActionResult Create([Bind(Include = "LastName,FirstName")] ApplicationUser applicationUser) { try { if (ModelState.IsValid) { db.Users.Add(applicationUser); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException ex) { //Log the error ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(applicationUser)); }
public ActionResult Create([Bind(Include = "ApplicationUserID,TrackingNumber,Name,StreetAddress,City,State,Zip")] Order order) { try { if (ModelState.IsValid) { db.Orders.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException ex) { //Log the error ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } ViewBag.ApplicationUserID = new SelectList(db.Users, "ID", "LastName", order.ApplicationUserID); return(View(order)); }