예제 #1
0
        public ProductModelDetail GetByProductId(int productId)
        {
            ProductModelDetail obj = new ProductModelDetail();

            //ProductEntity obj = new ProductEntity();
            try
            {
                obj = Execute(() => GetByProductIdNoCache(productId), "ProductBo:GetByProductId", Const.MediumCacheTime, false, productId);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.LogType.Error, ex.ToString());
            }
            return(obj);
        }
예제 #2
0
        public ProductModelDetail GetByProductIdNoCache(int productId)
        {
            ProductModelDetail objModel   = new ProductModelDetail();
            ProductEntity      objProduct = _productDal.GetByProductId(productId);

            if (objProduct != null && objProduct.ProductID > 0)
            {
                CategoryEntity category = _categoryBo.GetByCateId(objProduct.CatalogID);
                if (category != null && category.CatalogID > 0)
                {
                    objModel = new ProductModelDetail(objProduct, category);
                }
            }
            return(objModel);
        }
예제 #3
0
        public ActionResult ProductDetail(int productId)
        {
            ProductModelDetail modelDetail = _productBo.GetByProductId(productId);

            if (modelDetail != null && modelDetail.ProductId > 0 && modelDetail.Status == (int)Enums.ProductStatus.Active)
            {
                #region Redirect Permanent 301

                var    currentUrl  = Request.RawUrl;
                string standardUrl = modelDetail.URL;
                string url301      = standardUrl;

                if (currentUrl.Contains("?utm_source"))
                {
                    string strUtm = currentUrl.Substring(currentUrl.IndexOf("?utm_source"), currentUrl.Length - currentUrl.IndexOf("?utm_source"));
                    url301 = string.Concat(url301, strUtm);
                }
                if (!currentUrl.Equals(url301))
                {
                    return(RedirectPermanent(string.Concat(Const.BaseUrlNoSlash, url301)));
                }

                #endregion

                #region Meta

                string strTitle = modelDetail.Name;
                string seoTitle = !string.IsNullOrEmpty(modelDetail.SEOTitle) ? modelDetail.SEOTitle : modelDetail.Name;
                string seoDesc  = !string.IsNullOrEmpty(modelDetail.SEODescription) ? modelDetail.SEODescription : modelDetail.ShortDescription;
                if (string.IsNullOrEmpty(seoDesc) && seoDesc.Length > 160)
                {
                    seoDesc = StringUtils.TrimText(seoDesc, 160);
                }
                string metaTags = SEO.Instance.BindingMeta(standardUrl, seoTitle, StringUtils.RemoveStrHtmlTags(seoDesc));
                ViewBag.MetaTitle    = seoTitle;
                ViewBag.Meta         = metaTags;
                ViewBag.MetaFacebook = SEO.AddMetaFacebook(modelDetail.Name, "article", seoDesc, Const.BaseUrlNoSlash + standardUrl, BuildLink.CropImage(modelDetail.Avatar, Const.FacebookAvatar));

                #endregion

                ViewBag.CateId = modelDetail.CateId;

                return(View(modelDetail));
            }

            Response.StatusCode = 404;
            return(null);
        }
예제 #4
0
 public ActionResult Index(ProductModelDetail model, int?page)
 {
     try
     {
         int            pageIndex = page != null ? page.Value : 1;
         int            pageSize  = 10;
         int            total     = 0;
         List <Product> lst       = daoProduct.getPageListProduct(model.categoryID, model.searchString, out total);
         model.lstCategory     = daoCategory.getAllProductCategory();
         model.pageListProduct = lst.ToPagedList <Product>(pageIndex, pageSize);
         return(View(model));
     }
     catch
     {
         SetAlert("Xẩy ra lỗi, hãy thử lại", "error");
         return(View(model));
     }
 }