예제 #1
0
        public async Task <ActionResult> Product(String id = "")
        {
            try
            {
                if (!IsModulActive(StoreConstants.ProductType))
                {
                    Logger.Trace("Navigation Modul is not active:" + StoreConstants.ProductType);
                    return(HttpNotFound("Not Found"));
                }
                int productId              = id.Split("-".ToCharArray()).Last().ToInt();
                var categoryTask           = ProductCategoryService.GetProductCategoryAsync(StoreId, productId);
                var productsPageDesignTask = PageDesignService.GetPageDesignByName(StoreId, ProductDetailPage);
                var productsTask           = ProductService.GetProductsByIdAsync(productId);


                await Task.WhenAll(productsTask, categoryTask, productsPageDesignTask);

                var product    = productsTask.Result;
                var pageDesign = productsPageDesignTask.Result;
                var category   = categoryTask.Result;
                var settings   = GetStoreSettings();

                ViewData[StoreConstants.MetaTagKeywords]    = product.Name;
                ViewData[StoreConstants.MetaTagDescription] = GeneralHelper.TruncateAtWord(GeneralHelper.StripHtml(product.Name + ", " + product.Description), 155);

                if (pageDesign == null)
                {
                    throw new Exception("PageDesing is null:" + ProductDetailPage);
                }
                if (product == null)
                {
                    throw new Exception("Product is NULL. ProductId:" + productId);
                }

                if (category == null)
                {
                    throw new Exception("ProductCategory is NULL.ProductId:" + productId);
                }


                ProductHelper.StoreSettings = settings;
                ProductHelper.ImageWidth    = GetSettingValueInt("ProductsDetail_ImageWidth", 50);
                ProductHelper.ImageHeight   = GetSettingValueInt("ProductsDetail_ImageHeight", 50);
                ProductHelper.StoreSettings = GetStoreSettings();
                var dic = ProductHelper.GetProductsDetailPage(product, pageDesign, category);
                dic.MyStore       = this.MyStore;
                dic.StoreSettings = settings;
                dic.PageTitle     = product.Name;
                dic.MyStore       = this.MyStore;
                dic.PageTitle     = product.Name;
                return(View(dic));
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "ProductsController:Product:" + ex.StackTrace);
                return(RedirectToAction("Index"));
            }
        }
예제 #2
0
        public async Task <ActionResult> Category(String id = "", int page = 1)
        {
            try
            {
                if (!IsModulActive(StoreConstants.ProductType))
                {
                    Logger.Trace("Navigation Modul is not active:" + StoreConstants.ProductType);
                    return(HttpNotFound("Not Found"));
                }

                int categoryId     = id.Split("-".ToCharArray()).Last().ToInt();
                var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, CategoryPageDesingName);
                var categoryTask   = ProductCategoryService.GetProductCategoryAsync(categoryId);

                var settings = GetStoreSettings();
                ProductCategoryHelper.StoreSettings = settings;
                ProductCategoryHelper.ImageWidth    = GetSettingValueInt("ProductCategoryPage_ImageWidth", 50);
                ProductCategoryHelper.ImageHeight   = GetSettingValueInt("ProductCategoryPage_ImageHeight", 50);


                await Task.WhenAll(pageDesignTask, categoryTask);

                var pageDesign = pageDesignTask.Result;
                var category   = categoryTask.Result;

                if (pageDesign == null)
                {
                    throw new Exception("PageDesing is null" + CategoryPageDesingName);
                }


                var pageOutput = ProductCategoryHelper.GetCategoryPage(pageDesign, category);
                pageOutput.StoreSettings = settings;
                pageOutput.MyStore       = this.MyStore;
                pageOutput.PageTitle     = category.Name;
                return(View(pageOutput));
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Category:Index:" + ex.StackTrace, id);
                throw ex;
            }
        }