Esempio n. 1
0
        public async Task <ActionResult> Create([Bind(Include = "id,name")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Category.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public async Task <ActionResult> Create([Bind(Include = "id,name,catid,imageurl,price,isactive,description")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Product.Add(product);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.catid = new SelectList(db.Category, "id", "name", product.catid);
            return(View(product));
        }