Exemple #1
0
        public ActionResult Create([Bind(Include = "UserId,Email,Password,FirstName,LastName")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Exemple #2
0
        public ActionResult Create([Bind(Include = "ItemId,Name,Description,Price")] Item item)
        {
            if (ModelState.IsValid)
            {
                db.Items.Add(item);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(item));
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "OrderId,UserId,DateCreated")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.Users, "UserId", "Email", order.UserId);
            return(View(order));
        }