public ActionResult Edit(int id, ProductListWrapper pwrap)
        {
            try {
                if (!ModelState.IsValid)
                {
                    ViewData["categories"] = new SelectList(nwa.GetAllCategories());
                    ViewData["suppliers"]  = new SelectList(nwa.GetAllSuppliers());
                    return(View("Edit", pwrap));
                }

                Product prod = nwa.GetProduct(id);
                if (prod != null)
                {
                    ProductListWrapper wrapper = new ProductListWrapper()
                    {
                        product = prod
                    };
                    UpdateModel(wrapper);
                    prod.SupplierID = nwa.GetSupplierID(wrapper.SelectedSupplier);
                    prod.CategoryID = nwa.GetCategoryID(wrapper.SelectedCategory);
                    nwa.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    throw new NoSuchRecordException();
                }
            } catch {
                return(View());
            }
        }
        //
        // GET: /Product/Edit/5

        public ActionResult Edit(int id)
        {
            ViewData["categories"] = new SelectList(nwa.GetAllCategories());
            ViewData["suppliers"]  = new SelectList(nwa.GetAllSuppliers());

            Product prod = nwa.GetProduct(id);

            ProductListWrapper wrap = new ProductListWrapper()
            {
                product          = prod,
                SelectedCategory = prod.Category.CategoryName,
                SelectedSupplier = prod.Supplier.CompanyName,
            };

            return(View(wrap));
        }