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)); }
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); HomePageHelper.StoreId = this.StoreId; HomePageHelper.StoreSettings = 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 = HomePageHelper.GetHomePageDesign(pageDesing, sliderImages, products, blogs, news, categories, productCategories); liquidResult.MyStore = this.MyStore; return(View(liquidResult)); }
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(); HomePageHelper.StoreSettings = settings; HomePageHelper.StoreId = this.StoreId; var pageDesing = pageDesignTask.Result; var sliderImages = sliderTask.Result; StoreLiquidResult liquidResult = HomePageHelper.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)); }