public ActionResult Show(string categoryurl, string productid) { try { var prodrec = (from c in db.tblProducts where c.ProductNo == productid select c).FirstOrDefault(); ManageProductViewModel MPVM = new ManageProductViewModel(db); MPVM.BuildVM(prodrec.ProductId); ViewBag.Title = MPVM.currentVM.prodrec.tblCategory.headTitle + " - Product Number: " + prodrec.ProductNo; ViewBag.Description = MPVM.currentVM.prodrec.tblCategory.headDescription + " - Product Number: " + prodrec.ProductNo; ViewBag.Keywords = MPVM.currentVM.prodrec.tblCategory.headKeywords; ViewBag.DivBack = "specifications1"; if (MPVM.currentVM.prodrec.ProductNo.StartsWith("VMS")) { ViewBag.DivBack = "vmsbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLST")) { ViewBag.DivBack = "blsmagbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLDT")) { ViewBag.DivBack = "bldmagbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLDM")) { ViewBag.DivBack = "bldbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLSM")) { ViewBag.DivBack = "blsbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("NCM")) { ViewBag.DivBack = "ncmbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("VMS")) { ViewBag.DivBack = "vmsbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("STP")) { ViewBag.DivBack = "platensbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("P12")) { ViewBag.DivBack = "platensbox1"; } return View(MPVM.currentVM); } catch { return RedirectToAction("NoProduct", "Error"); } }
public ActionResult ShowProduct(int productid) { try { ManageProductViewModel MPVM = new ManageProductViewModel(db); MPVM.BuildVM(productid); ViewBag.Title = MPVM.currentVM.prodrec.tblCategory.headTitle; ViewBag.Description = MPVM.currentVM.prodrec.tblCategory.headDescription; ViewBag.Keywords = MPVM.currentVM.prodrec.tblCategory.headKeywords; //if (MPVM.currentVM.prodrec.ProductNo) ; //if(MPVM.currentVM.prodrec.ProductNo) ViewBag.DivBack = "specifications1"; if (MPVM.currentVM.prodrec.ProductNo.StartsWith("VMS")) { ViewBag.DivBack = "vmsbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLST")) { ViewBag.DivBack = "blsmagbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLDT")) { ViewBag.DivBack = "bldmagbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLDM")) { ViewBag.DivBack = "bldbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("BLSM")) { ViewBag.DivBack = "blsbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("NCM")) { ViewBag.DivBack = "ncmbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("VMS")) { ViewBag.DivBack = "vmsbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("STP")) { ViewBag.DivBack = "platensbox1"; } if (MPVM.currentVM.prodrec.ProductNo.StartsWith("P12")) { ViewBag.DivBack = "platensbox1"; } // I believe this is where the redirect works via the SLUG string redirUrl = "../product/" + MPVM.currentVM.prodrec.tblCategory.CategoryPageUrl + "/" + MPVM.currentVM.prodrec.ProductNo; return RedirectPermanent(redirUrl); //return View(MPVM.currentVM); } catch { return RedirectToAction("NoProduct", "Error"); } }