Esempio n. 1
0
        public ActionResult Create([Bind(Include = "CategoryID,CategoryName")]
                                   Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public ActionResult Create(
            [Bind(Include = "ProductID,EAN,Title,productName,productDescription,CategoryID,validFrom")]
            Product product)
        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);
            return(View(product));
        }