public ActionResult Detail(int productId, int carModelId, int carBrandId, string parentUrl, string parentName) { helperProductDetail helperPage = new helperProductDetail(); var productItem = db.tbl_product.Include("tbl_stock").Include("tbl_gallery").Include("tbl_productCritear.tbl_critear").Where(a => a.productId == productId).FirstOrDefault(); var carBrandItem = db.tbl_carBrand.Where(a => a.carBrandId == carBrandId).FirstOrDefault(); var carModelItem = db.tbl_carModel.Include("tbl_carModelProduct.tbl_product.tbl_stock").Where(a => a.carModelId == carModelId).FirstOrDefault(); var baseUrl = mainPath + langCode + "/" + parentUrl + "/" + carBrandItem.url + "/" + carModelItem.url; // statu Control if (productItem.statu == false) { return RedirectPermanent(baseUrl + ".html"); } // stockControl if (!productItem.tbl_stock.Any(a => a.stockCount > 0)) { return RedirectPermanent(baseUrl + ".html"); } //PrevAndNextUrl var productList = carModelItem.tbl_carModelProduct.Select(a => a.tbl_product).Where(a => a != null && a.statu && a.tbl_stock.Any(b => b.stockCount > 0)).OrderBy(a => a.sequence).ToList(); var sequenceCurrenProduct = productList.IndexOf(productItem); helperPage = getPrevAndNextUrl(helperPage, sequenceCurrenProduct, productList, baseUrl); //backLink helperPage.backLink = baseUrl + ".html"; if (Request.QueryString["page"] != null) { // ToDo: Add Pageing Back Link } productShared pc = new productShared(db); CultureInfo priceFormat = CultureInfo.CreateSpecificCulture(langCulture); //breadcrumb helperPage.breadCrumbItem = getProductDetailBreadCrumbProductList(parentName, parentUrl, carBrandItem.name, carBrandItem.url, carModelItem.name, carModelItem.url, productItem.name); helperPage.imageList = pc.getProductGallery(productItem, "500", "350"); helperPage.productName = productItem.name; helperPage.productId = productItem.productId; decimal price = pc.calcPriceProduct(productItem); helperPage.price = price.ToString("F2", priceFormat) + " TL"; var taxpriceItem = pc.getProductWithoutTaxPriceAndTaxPrice(productItem, priceFormat); helperPage.withoutTaxPrice = taxpriceItem.Item2; helperPage.detail = productItem.detail; //OptionList helperPage.optionList = pc.getOptionListByProductItem(productItem); if (Request.QueryString["action"] != null && Request.QueryString["action"] == "optionSelect") { helperPage.isOptionMsgExist = true; } //Title var settingItem = db.tbl_settings.Where(a => a.langId == langId).FirstOrDefault(); if (settingItem != null) { helperPage.setBrowserTitle(helperPage.productName + settingItem.allPageTitle); helperPage.setDescription(productItem.metaDescription); helperPage.setKeywords(productItem.metaKeyword); } if (settingItem.isCrediCardEnable.HasValue && settingItem.isCrediCardEnable.Value) { helperPage.isInstallmenTableVisible = true; } return View(helperPage); }
private helperProductDetail getPrevAndNextUrl(helperProductDetail helperPage, int sequenceCurrenProduct, List<tbl_product> productList, string baseUrl) { // prev product Url if (sequenceCurrenProduct != 0) { helperPage.isBackProductUrlExist = true; helperPage.backProductUrl = baseUrl + "/" + productList[sequenceCurrenProduct - 1].url + ".html"; } else { helperPage.isBackProductUrlExist = false; } // next product Url if (sequenceCurrenProduct < productList.Count - 1) { helperPage.isNextProductUrlExist = true; helperPage.nextProductUrl = baseUrl + "/" + productList[sequenceCurrenProduct + 1].url + ".html"; } else { helperPage.isNextProductUrlExist = false; } return helperPage; }