Exemple #1
0
        public ActionResult Create([Bind(Include = "CompanyId,Name")] Company company)
        {
            if (ModelState.IsValid)
            {
                db.Company.Add(company);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(company));
        }
        public ActionResult Create([Bind(Include = "Id,ProductName,CompanyId,Price,Active,Stock,IdDeleted")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyId = new SelectList(db.Company, "CompanyId", "Name", product.CompanyId);
            return(View(product));
        }