// GET: Products/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TblProduct tblProduct = db.TblProducts.Find(id); if (tblProduct == null) { return(HttpNotFound()); } IEnumerable <TblProductAttribute> tblProductAttributes = db.TblProductAttributes.Where(e => e.ProductID == id).Include(e => e.TblAttribute).ToList(); IEnumerable <TblProductImage> tblProductImage = db.TblProductImages.Where(e => e.ProductID == id).ToList(); CompleteProductInfo completeProductInfo = new CompleteProductInfo(); completeProductInfo.TblProduct = tblProduct; completeProductInfo.tblProductAttributes = tblProductAttributes; completeProductInfo.tblProductImages = tblProductImage; return(View(completeProductInfo)); }
public ActionResult ProductDetails(string title) { if (title == null || title == "") { return(RedirectToAction("PageNotFound")); } //---------------- var storeId = 6; if (geturl() != "http://localhost:50279") { var url2 = geturl(); var StoreInformation = db.TblStoreInformations.Where(e => e.IsActive == true && e.IsDelete == false && e.StoreURL == url2).OrderByDescending(e => e.CreatedDate).FirstOrDefault(); if (StoreInformation == null) { return(RedirectToAction("StoreNotAvailable")); } storeId = StoreInformation.StoreId; } // ---------------------- var product = db.TblProducts.Where(e => e.SlugURL == title && e.IsActive == true && e.IsDelete == false && e.StoreId == storeId).FirstOrDefault(); if (product == null) { return(RedirectToAction("PageNotFound")); } product.Views = product.Views + 1; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); CompleteProductInfo completeProductInfo = new CompleteProductInfo(); completeProductInfo.TblProduct = product; completeProductInfo.tblProductAttributes = db.TblProductAttributes.Where(e => e.ProductID == product.ProductID).OrderByDescending(e => e.CreatedDate).ToList(); completeProductInfo.tblProductImages = db.TblProductImages.Where(e => e.ProductID == product.ProductID).ToList(); return(View(completeProductInfo)); }