コード例 #1
0
        private async Task <String> GetProductCategoriesHtml(string designName, int imageWidth, int imageHeight)
        {
            string returnHtml;
            var    categoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType,
                                                                                              true);
            var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, designName);

            ProductCategoryHelper.StoreSettings = GetStoreSettings();
            ProductCategoryHelper.ImageWidth    = imageWidth == 0
                                                   ? GetSettingValueInt("ProductCategoriesPartial_ImageWidth", 50)
                                                   : imageWidth;
            ProductCategoryHelper.ImageHeight = imageHeight == 0
                                                    ? GetSettingValueInt("ProductCategoriesPartial_ImageHeight", 50)
                                                    : imageHeight;

            await Task.WhenAll(categoriesTask, pageDesignTask);

            var categories = categoriesTask.Result;
            var pageDesign = pageDesignTask.Result;

            var pageOuput = ProductCategoryHelper.GetProductCategoriesPartial(categories, pageDesign);

            returnHtml = pageOuput.PageOutputText;

            return(returnHtml);
        }
コード例 #2
0
        public async Task <ActionResult> Products(int take = 1, int description = 300, int imageHeight = 50, int imageWidth = 50, int isDetailLink = 0)
        {
            // var productsTask = ProductService.GetProductsAsync(StoreId, take, true);
            var productsTask = ProductService.GetProductsByProductTypeAsync(StoreId, null, null, null, StoreConstants.ProductType, 1,
                                                                            take, true, "random", null);
            var productCategoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);
            var storeTask             = StoreService.GetStoreAsync(StoreId);

            await Task.WhenAll(storeTask, productsTask, productCategoriesTask);

            var store             = storeTask.Result;
            var products          = productsTask.Result;
            var productCategories = productCategoriesTask.Result;

            var feed = ProductHelper.GetProductsRssFeed(store, products, productCategories, description, isDetailLink);

            ProductHelper.ImageWidth  = imageWidth;
            ProductHelper.ImageHeight = imageHeight;
            ProductHelper.StoreId     = StoreId;
            var comment = new StringBuilder();

            comment.AppendLine("Take=Number of rss item; Default value is 10  ");
            comment.AppendLine("Description=The length of description text.Default value is 300  ");
            return(new FeedResult(feed, comment));
        }
コード例 #3
0
        public async Task <ActionResult> Index3(int page = 1, int catId = 0, String search = "", String filters = "")
        {
            try
            {
                if (!IsModulActive(StoreConstants.ProductType))
                {
                    return(HttpNotFound("Not Found"));
                }

                var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, IndexPageDesingName);
                var pageSize       = GetSettingValueInt("ProductsIndex_PageSize", StoreConstants.DefaultPageSize);
                var productsTask   = ProductService.GetProductsCategoryIdAsync(StoreId, catId, StoreConstants.ProductType, true, page, pageSize, search, filters);
                var categoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);

                var settings = GetStoreSettings();
                ProductService2.ImageWidth  = GetSettingValueInt("ProductsIndex_ImageWidth", 50);
                ProductService2.ImageHeight = GetSettingValueInt("ProductsIndex_ImageHeight", 50);


                await Task.WhenAll(pageDesignTask, productsTask, categoriesTask);

                var products   = productsTask.Result;
                var pageDesign = pageDesignTask.Result;
                var categories = categoriesTask.Result;



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


                var pageOutput           = ProductService2.GetProductsIndexPage(products, pageDesign, categories);
                var pagingPageDesignTask = PageDesignService.GetPageDesignByName(StoreId, "Paging");


                PagingService2.PageOutput      = pageOutput;
                PagingService2.HttpRequestBase = this.Request;
                PagingService2.RouteData       = this.RouteData;
                PagingService2.ActionName      = this.ControllerContext.RouteData.Values["action"].ToString();
                PagingService2.ControllerName  = this.ControllerContext.RouteData.Values["controller"].ToString();
                await Task.WhenAll(pagingPageDesignTask);

                var pagingDic = PagingService2.GetPaging(pagingPageDesignTask.Result);
                pagingDic.StoreSettings = settings;
                pagingDic.PageTitle     = "Products";
                pagingDic.MyStore       = this.MyStore;



                return(View(pagingDic));
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "ProductsController:Index:" + ex.StackTrace, page);
                return(new HttpStatusCodeResult(500));
            }
        }
コード例 #4
0
        public async Task <ActionResult> Index()
        {
            int blogsTake    = GetSettingValueInt("HomePageMainBlogsContents_ItemsNumber", StoreConstants.DefaultPageSize);
            int newsTake     = GetSettingValueInt("HomePageMainNewsContents_ItemsNumber", StoreConstants.DefaultPageSize);
            int productsTake = GetSettingValueInt("HomePageMainProductsContents_ItemsNumber", StoreConstants.DefaultPageSize);
            int sliderTake   = GetSettingValueInt("HomePageSliderImages_ItemsNumber", StoreConstants.DefaultPageSize);


            int?   categoryId = null;
            String key        = String.Format("Home:Index-{0}-{1}-{2}-{3}-{4}", StoreId, blogsTake, newsTake,
                                              productsTake, sliderTake);

            var pageDesignTask        = PageDesignService.GetPageDesignByName(StoreId, "HomePageWithMainData");
            var blogsTask             = ContentService.GetMainPageContentsAsync(StoreId, categoryId, StoreConstants.BlogsType, blogsTake);
            var newsTask              = ContentService.GetMainPageContentsAsync(StoreId, categoryId, StoreConstants.NewsType, newsTake);
            var productsTask          = ProductService.GetMainPageProductsAsync(StoreId, productsTake);
            var sliderTask            = FileManagerService.GetStoreCarouselsAsync(StoreId, sliderTake);
            var categoriesTask        = CategoryService.GetCategoriesByStoreIdAsync(StoreId, "", true);
            var productCategoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);

            // Create new stopwatch.
            Stopwatch stopwatch = new Stopwatch();

            // Begin timing.
            stopwatch.Start();



            await Task.WhenAll(productsTask, blogsTask, newsTask, pageDesignTask, sliderTask, categoriesTask,
                               productCategoriesTask);

            var settings = GetStoreSettings();

            HomePageHelper.StoreId       = this.StoreId;
            HomePageHelper.StoreSettings = settings;

            var products          = productsTask.Result;
            var blogs             = blogsTask.Result;
            var news              = newsTask.Result;
            var pageDesing        = pageDesignTask.Result;
            var sliderImages      = sliderTask.Result;
            var categories        = categoriesTask.Result;
            var productCategories = productCategoriesTask.Result;

            StoreLiquidResult liquidResult = HomePageHelper.GetHomePageDesign(pageDesing, sliderImages, products, blogs,
                                                                              news, categories, productCategories);

            liquidResult.PageTitle     = GetSettingValue("HomePage_Title", "");
            liquidResult.StoreSettings = settings;
            liquidResult.MyStore       = this.MyStore;


            // Stop timing.
            stopwatch.Stop();

            Logger.Info("Home:Index:Time elapsed: {0} elapsed milliseconds", stopwatch.ElapsedMilliseconds);
            return(View(liquidResult));
        }
コード例 #5
0
        public async Task <ActionResult> Index(int page = 1)
        {
            try
            {
                if (!IsModulActive(StoreConstants.ProductType))
                {
                    Logger.Trace("Navigation Modul is not active:" + StoreConstants.ProductType);
                    return(HttpNotFound("Not Found"));
                }

                var pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, IndexPageDesingName);
                var pageSize       = GetSettingValueInt("ProductCategories_PageSize", StoreConstants.DefaultPageSize);
                var categoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true, page, pageSize);
                var settings       = GetStoreSettings();
                ProductCategoryHelper.StoreSettings = settings;

                await Task.WhenAll(pageDesignTask, categoriesTask);

                var pageDesign = pageDesignTask.Result;
                var categories = categoriesTask.Result;

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


                var pageOutput           = ProductCategoryHelper.GetCategoriesIndexPage(pageDesign, categories);
                var pagingPageDesignTask = PageDesignService.GetPageDesignByName(StoreId, "Paging");


                PagingHelper.StoreSettings   = GetStoreSettings();
                PagingHelper.StoreId         = StoreId;
                PagingHelper.PageOutput      = pageOutput;
                PagingHelper.HttpRequestBase = this.Request;
                PagingHelper.RouteData       = this.RouteData;
                PagingHelper.ActionName      = this.ControllerContext.RouteData.Values["action"].ToString();
                PagingHelper.ControllerName  = this.ControllerContext.RouteData.Values["controller"].ToString();
                await Task.WhenAll(pagingPageDesignTask);

                var pagingDic = PagingHelper.GetPaging(pagingPageDesignTask.Result);
                pagingDic.StoreSettings = settings;
                pagingDic.MyStore       = this.MyStore;
                pageOutput.PageTitle    = "Product Categories";
                return(View(pagingDic));
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "ProductCategories:Index:" + ex.StackTrace, page);
                throw ex;
            }
        }
コード例 #6
0
        private async Task <String> GetProductsByProductTypeHtml(int page, string designName, int categoryId, int brandId, int retailerId, int pageSize,
                                                                 int imageWidth, int imageHeight, string productType, int excludedProductId)
        {
            string returnHtml = "";


            Task <List <Product> > productsTask = null;
            var catId      = categoryId == 0 ? (int?)null : categoryId;
            var retId      = retailerId == 0 ? (int?)null : retailerId;
            var bId        = brandId == 0 ? (int?)null : brandId;
            var eProductId = excludedProductId == 0 ? (int?)null : excludedProductId;

            Logger.Trace("StoreId " + StoreId +
                         " designName:" +
                         designName +
                         " categoryId:" +
                         categoryId + " brandId:" +
                         brandId + " pageSize:" + pageSize + " page:" +
                         page + " imageWidth:" + imageWidth + " imageHeight:" + imageHeight + " productType:" + productType);

            ProductService2.ImageWidth  = imageWidth;
            ProductService2.ImageHeight = imageHeight;

            int take = pageSize;
            int skip = (page - 1) * pageSize;

            productsTask = ProductService.GetProductsByProductTypeAsync(StoreId, catId, bId, retId, StoreConstants.ProductType, take,
                                                                        skip, true, productType, eProductId);
            var pageDesignTask        = PageDesignService.GetPageDesignByName(StoreId, designName);
            var productCategoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId,
                                                                                                  StoreConstants
                                                                                                  .ProductType, true);

            await Task.WhenAll(pageDesignTask, productsTask, productCategoriesTask);

            var products          = productsTask.Result;
            var pageDesign        = pageDesignTask.Result;
            var productCategories = productCategoriesTask.Result;


            var pageOuput = ProductService2.GetPopularProducts(products, productCategories, pageDesign);

            returnHtml = pageOuput.PageOutputText;

            return(returnHtml);
        }
コード例 #7
0
        public async Task <ActionResult> Index(
            String search  = "",
            String filters = "",
            String page    = "",
            String id      = "clothes-shoes-and-jewelry")
        {
            search = search.ToStr();
            id     = String.IsNullOrEmpty(id) ? "clothes-shoes-and-jewelry" : id;
            String categoryApiId = id;

            RouteData.Values["id"] = id;
            String headerText = "";
            var    fltrs      = FilterHelper.ParseFiltersFromString(filters);

            if (fltrs.Any())
            {
                headerText = String.Join("– ", fltrs.Select(r => r.Text.ToTitleCase()));
            }

            if (!string.IsNullOrEmpty(search))
            {
                headerText += " '" + search.ToTitleCase() + "'";
            }



            int iPage = page.ToInt(); if (iPage == 0)
            {
                iPage = 1;
            }
            var pageSize                = GetSettingValueInt("ProductsIndex_PageSize", StoreConstants.DefaultPageSize);
            int skip                    = (iPage - 1) * pageSize;
            var categoriesTask          = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);
            var pageDesignTask          = PageDesignService.GetPageDesignByName(StoreId, "ProductsSearchIndexPage");
            var productSearchResultTask = ProductService.GetProductsSearchResult(StoreId, search, filters, pageSize, skip, false, categoryApiId);
            await Task.WhenAll(productSearchResultTask, categoriesTask, pageDesignTask);

            var productSearchResult = productSearchResultTask.Result;
            var pageDesign          = pageDesignTask.Result;
            var categories          = categoriesTask.Result;

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

            var settings   = GetStoreSettings();
            var pageOutput = ProductService2.GetProductsSearchPage(this, productSearchResult, pageDesign, categories, search, filters, headerText, categoryApiId);

            var pagingPageDesignTask = PageDesignService.GetPageDesignByName(StoreId, "Paging");

            PagingService2.PageOutput      = pageOutput;
            PagingService2.HttpRequestBase = this.Request;
            PagingService2.RouteData       = this.RouteData;
            PagingService2.ActionName      = this.ControllerContext.RouteData.Values["action"].ToStr();
            PagingService2.ControllerName  = this.ControllerContext.RouteData.Values["controller"].ToStr();
            await Task.WhenAll(pagingPageDesignTask);

            var pagingDic = PagingService2.GetPaging(pagingPageDesignTask.Result);

            pagingDic.StoreSettings = settings;
            pagingDic.PageTitle     = pageOutput.PageTitle;
            pagingDic.MyStore       = this.MyStore;


            pagingDic.DetailLink = "/products/" + categoryApiId;
            pagingDic.PageTitle  = String.IsNullOrEmpty(headerText) ?  pagingDic.PageTitle  : headerText;
            string mmm =
                GetFilter(productSearchResult.Filters, "category", 4) + " " +
                GetFilter(productSearchResult.Filters, "brand", 20);

            ViewData[StoreConstants.MetaTagKeywords]    = pagingDic.PageTitle + ", " + mmm;
            ViewData[StoreConstants.MetaTagDescription] = GeneralHelper.TruncateAtWord(pagingDic.PageTitle + ", " + mmm, 155);

            return(View(pagingDic));
        }
コード例 #8
0
        private async Task <String> GetProductsByProductTypeHtml(int page, string designName, int categoryId, int brandId, int retailerId, int pageSize,
                                                                 int imageWidth, int imageHeight, string productType, int excludedProductId)
        {
            string returnHtml = "";


            Task <List <Product> > productsTask = null;
            var catId      = categoryId == 0 ? (int?)null : categoryId;
            var retId      = retailerId == 0 ? (int?)null : retailerId;
            var bId        = brandId == 0 ? (int?)null : brandId;
            var eProductId = excludedProductId == 0 ? (int?)null : excludedProductId;

            Logger.Trace("StoreId " + StoreId +
                         " designName:" +
                         designName +
                         " categoryId:" +
                         categoryId + " brandId:" +
                         brandId + " pageSize:" + pageSize + " page:" +
                         page + " imageWidth:" + imageWidth + " imageHeight:" + imageHeight + " productType:" + productType);

            if (productType.Equals("random"))
            {
                pageSize = pageSize == 0
                               ? GetSettingValueInt("RandomProducts_PageSize", StoreConstants.DefaultPageSize)
                               : pageSize;
                ProductHelper.ImageWidth  = imageWidth == 0 ? GetSettingValueInt("RandomProducts_ImageWidth", 99) : imageWidth;
                ProductHelper.ImageHeight = imageHeight == 0
                                                ? GetSettingValueInt("RandomProducts_ImageHeight", 99)
                                                : imageHeight;
            }
            else if (productType.Equals("normal"))
            {
                pageSize = pageSize == 0
                               ? GetSettingValueInt("NormalProducts_PageSize", StoreConstants.DefaultPageSize)
                               : pageSize;
                ProductHelper.ImageWidth  = imageWidth == 0 ? GetSettingValueInt("NormalProducts_ImageWidth", 99) : imageWidth;
                ProductHelper.ImageHeight = imageHeight == 0
                                                ? GetSettingValueInt("NormalProducts_ImageHeight", 99)
                                                : imageHeight;
            }
            else if (productType.Equals("popular"))
            {
                pageSize = pageSize == 0
                               ? GetSettingValueInt("PopularProducts_PageSize", StoreConstants.DefaultPageSize)
                               : pageSize;
                ProductHelper.ImageWidth  = imageWidth == 0 ? GetSettingValueInt("PopularProducts_ImageWidth", 99) : imageWidth;
                ProductHelper.ImageHeight = imageHeight == 0
                                                ? GetSettingValueInt("PopularProducts_ImageHeight", 99)
                                                : imageHeight;
            }
            else if (productType.Equals("recent"))
            {
                pageSize = pageSize == 0
                               ? GetSettingValueInt("RecentProducts_PageSize", StoreConstants.DefaultPageSize)
                               : pageSize;
                ProductHelper.ImageWidth  = imageWidth == 0 ? GetSettingValueInt("RecentProducts_ImageWidth", 99) : imageWidth;
                ProductHelper.ImageHeight = imageHeight == 0
                                                ? GetSettingValueInt("RecentProducts_ImageHeight", 99)
                                                : imageHeight;
            }
            else if (productType.Equals("main"))
            {
                pageSize = pageSize == 0
                               ? GetSettingValueInt("MainProducts_PageSize", StoreConstants.DefaultPageSize)
                               : pageSize;
                ProductHelper.ImageWidth  = imageWidth == 0 ? GetSettingValueInt("MainProducts_ImageWidth", 99) : imageWidth;
                ProductHelper.ImageHeight = imageHeight == 0 ? GetSettingValueInt("MainProducts_ImageHeight", 99) : imageHeight;
            }
            else if (productType.Equals("discount"))
            {
                pageSize = pageSize == 0
                               ? GetSettingValueInt("DiscountProducts_PageSize", StoreConstants.DefaultPageSize)
                               : pageSize;
                ProductHelper.ImageWidth  = imageWidth == 0 ? GetSettingValueInt("DiscountProducts_ImageWidth", 99) : imageWidth;
                ProductHelper.ImageHeight = imageHeight == 0
                                                ? GetSettingValueInt("DiscountProducts_ImageHeight", 99)
                                                : imageHeight;
            }

            productsTask = ProductService.GetProductsByProductTypeAsync(StoreId, catId, bId, retId, StoreConstants.ProductType, page,
                                                                        pageSize, true, productType, eProductId);
            var pageDesignTask        = PageDesignService.GetPageDesignByName(StoreId, designName);
            var productCategoriesTask = ProductCategoryService.GetProductCategoriesByStoreIdAsync(StoreId,
                                                                                                  StoreConstants
                                                                                                  .ProductType, true);

            await Task.WhenAll(pageDesignTask, productsTask, productCategoriesTask);

            var products          = productsTask.Result;
            var pageDesign        = pageDesignTask.Result;
            var productCategories = productCategoriesTask.Result;

            ProductHelper.StoreSettings = GetStoreSettings();


            var pageOuput = ProductHelper.GetPopularProducts(products, productCategories, pageDesign);

            returnHtml = pageOuput.PageOutputText;

            return(returnHtml);
        }