Exemple #1
0
        private void PopulateViewBagWithVendorIDandProductIDSelectLists(VendorProductCreateViewModel vendorProductCreateViewModel)
        {
            VendorProduct vendorProduct = new VendorProduct {
                VendorID  = vendorProductCreateViewModel.VendorID,
                ProductID = vendorProductCreateViewModel.ProductID
            };

            PopulateViewBagWithVendorIDandProductIDSelectLists(vendorProduct);
        }
Exemple #2
0
        public ActionResult Create(VendorProductCreateViewModel vendorProductCreateViewModel)
        {
            if (ModelState.IsValid)
            {
                VendorProduct vp = new VendorProduct {
                    VendorID  = vendorProductCreateViewModel.VendorID,
                    ProductID = vendorProductCreateViewModel.ProductID,
                    UnitPrice = vendorProductCreateViewModel.UnitPrice
                };

                db.VendorProducts.Add(vp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            PopulateViewBagWithVendorIDandProductIDSelectLists(vendorProductCreateViewModel);

            return(View(vendorProductCreateViewModel));
        }