// GET: ProductController/Create public ActionResult Create() { //passing all the product characteristics to view to create dropdown menus ProductCharacteristics productCharacteristics = new ProductCharacteristics(); DisplayDbData.DisplayProductCharacteristics(productCharacteristics); ViewBag.ProductCharacteristics = productCharacteristics; return(View(new Product())); }
// GET: ProductController/Edit/ public ActionResult Edit(int Id) { try { var product = DisplayDbData.GetProductById(new Product(), Id); ProductCharacteristics productCharacteristics = new ProductCharacteristics(); DisplayDbData.DisplayProductCharacteristics(productCharacteristics); ViewBag.ProductCharacteristics = productCharacteristics; return(View(product)); } catch (Exception) { ViewBag.Message = "Product not found"; return(RedirectToAction(nameof(Index))); throw; } }