// // GET: /NorthwindSvr/Edit/5 public ActionResult EditProduct(int id, AllProductsModel allProductsModel, SuppliersCategoriesModel suppliersCategoriesModel) { Product p = allProductsModel.ProductById(id); ViewBag.SuppliersCategoriesModel = suppliersCategoriesModel; return(View(p)); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { // get the model from the session SuppliersCategoriesModel suppliersCategoriesModel = (SuppliersCategoriesModel)controllerContext.HttpContext.Session[sessionKey]; if (suppliersCategoriesModel == null) { suppliersCategoriesModel = new SuppliersCategoriesModel(); controllerContext.HttpContext.Session[sessionKey] = suppliersCategoriesModel; } return(suppliersCategoriesModel); }
// // GET: /NorthwindSvr/Create public ActionResult CreateProduct(SuppliersCategoriesModel model) { ViewBag.SuppliersCategoriesModel = model; return(View(new Product())); }
// // GET: /NorthwindSvr/Details/5 public ActionResult DetailsProduct(int?id, AllProductsModel allProductsModel, SuppliersCategoriesModel model) { Product p = null; if (id != null) { p = allProductsModel.ProductById(id.Value); } else { p = allProductsModel.ProductById((int)TempData["id"]); } if (p.Supplier == null) { p.Supplier = model.SupplierList.Where(s => s.SupplierID == p.SupplierID).DefaultIfEmpty(null).First(); } if (p.Category == null) { p.Category = model.CategoryList.Where(c => c.CategoryID == p.CategoryID).DefaultIfEmpty(null).First(); } return(View(p)); }
public ActionResult EditProduct(Product p, SuppliersCategoriesModel suppliersCategoriesModel) { NorthwindSvr.UpdateProduct(p, true); ViewBag.SuppliersCategoriesModel = suppliersCategoriesModel; return(View(p)); }