示例#1
0
        public async Task <ActionResult> Index2()
        {
            int sliderTake = GetSettingValueInt("HomePageSliderImages_ItemsNumber", StoreConstants.DefaultPageSize);

            var       pageDesignTask = PageDesignService.GetPageDesignByName(StoreId, "HomePage");
            var       sliderTask     = FileManagerService.GetStoreCarouselsAsync(StoreId, sliderTake);
            Stopwatch stopwatch      = new Stopwatch();

            // Begin timing.
            stopwatch.Start();


            await Task.WhenAll(pageDesignTask, sliderTask);

            var settings = GetStoreSettings();


            var pageDesing   = pageDesignTask.Result;
            var sliderImages = sliderTask.Result;


            StoreLiquidResult liquidResult = ProductService2.GetHomePageDesign(pageDesing, sliderImages);

            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));
        }
示例#2
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));
            }
        }
示例#3
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);
                }


                ProductService2.ImageWidth  = GetSettingValueInt("ProductsDetail_ImageWidth", 50);
                ProductService2.ImageHeight = GetSettingValueInt("ProductsDetail_ImageHeight", 50);
                var dic = ProductService2.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"));
            }
        }
示例#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();

            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 = ProductService2.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> Index3()
        {
            int?categoryId = null;

            String ConnectionString = "Stores";

            var rep  = new ProductRepository(new StoreContext(ConnectionString));
            var rep2 = new ContentRepository(new StoreContext(ConnectionString));
            var rep3 = new PageDesignRepository(new StoreContext(ConnectionString));
            var rep4 = new ProductCategoryRepository(new StoreContext(ConnectionString));
            var rep5 = new CategoryRepository(new StoreContext(ConnectionString));
            var rep6 = new FileManagerRepository(new StoreContext(ConnectionString));



            var productsTask          = rep.GetProductsByBrandAsync(StoreId, 5, 100, null);
            var pageDesignTask        = rep3.GetPageDesignByName(StoreId, "HomePage");
            var blogsTask             = rep2.GetMainPageContentsAsync(StoreId, categoryId, StoreConstants.BlogsType, 5);
            var newsTask              = rep2.GetMainPageContentsAsync(StoreId, categoryId, StoreConstants.NewsType, 5);
            var productCategoriesTask = rep4.GetProductCategoriesByStoreIdAsync(StoreId, StoreConstants.ProductType, true);
            var categoriesTask        = rep5.GetCategoriesByStoreIdAsync(StoreId, StoreConstants.NewsType, true);
            var sliderTask            = rep6.GetStoreCarouselsAsync(StoreId, 58);



            //IProductService rep = ProductService;
            //IContentService rep2 = ContentService;
            //IPageDesignService rep3 = PageDesignService;
            //IProductCategoryService rep4 = ProductCategoryService;
            //ICategoryService rep5 = CategoryService;
            //IFileManagerService rep6 = FileManagerService;

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



            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 = ProductService2.GetHomePageDesign(pageDesing, sliderImages, products, blogs,
                                                                               news, categories, productCategories);

            liquidResult.MyStore = this.MyStore;


            return(View(liquidResult));
        }
示例#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> 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 = ProductService2.GetProductsRssFeed(store, products, productCategories, description, isDetailLink);

            ProductService2.ImageWidth  = imageWidth;
            ProductService2.ImageHeight = imageHeight;
            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));
        }
示例#8
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));
        }
        //
        // GET: /Products/
        public ActionResult Product(String id)
        {
            ProductDetailViewModel resultModel = ProductService2.GetProductDetailPage(id);

            return(View(resultModel));
        }
        public ActionResult Index(String search = "", String page = "1")
        {
            ProductsViewModel resultModel = ProductService2.GetProductIndexPage(search, page);

            return(View(resultModel));
        }
示例#11
0
        public ActionResult Index()
        {
            StoreHomePage resultModel = ProductService2.GetHomePage();

            return(View(resultModel));
        }
示例#12
0
 public ActionResult Products(int take = 1, int description = 300, int imageHeight = 50, int imageWidth = 50, int isDetailLink = 0)
 {
     return(ProductService2.GetProductRss(take, description, imageHeight, imageWidth, isDetailLink));
 }