Esempio n. 1
0
        //
        // Products/New

        public ActionResult New()
        {
            var viewData = new ProductsNewViewData
            {
                Suppliers  = new SelectList(northwind.GetSuppliers(), "SupplierID", "CompanyName"),
                Categories = new SelectList(northwind.GetCategories(), "CategoryID", "CategoryName")
            };

            return(View("New", viewData));
        }
    public ActionResult Edit(int id)
    {
        var viewData = new ProductsEditViewData {
            Product = northwind.GetProductById(id)
        };

        viewData.Categories = new SelectList(northwind.GetCategories(), "CategoryID", "CategoryName", viewData.Product.CategoryID);
        viewData.Suppliers  = new SelectList(northwind.GetSuppliers(), "SupplierID", "CompanyName", viewData.Product.SupplierID);
        return(View("Edit", viewData));
    }