/// <summary> /// Gets all contact attributes /// </summary> /// <param name="storeId">Store identifier</param> /// <returns>Contact attributes</returns> public virtual async Task <IList <ContactAttribute> > GetAllContactAttributes(string storeId = "", bool ignorAcl = false) { string key = string.Format(CacheKey.CONTACTATTRIBUTES_ALL_KEY, storeId, ignorAcl); return(await _cacheBase.GetAsync(key, () => { var query = _contactAttributeRepository.Table; query = query.OrderBy(c => c.DisplayOrder); if ((!String.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations) || (!ignorAcl && !CommonHelper.IgnoreAcl)) { if (!ignorAcl && !CommonHelper.IgnoreAcl) { var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds(); query = from p in query where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x)) select p; } //Store acl if (!String.IsNullOrEmpty(storeId) && !CommonHelper.IgnoreStoreLimitations) { query = from p in query where !p.LimitedToStores || p.Stores.Contains(storeId) select p; } } return query.ToListAsync(); })); }
/// <summary> /// Gets all languages /// </summary> /// <param name="storeId">Load records allowed only in a specified store; pass "" to load all records</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Languages</returns> public virtual async Task <IList <Language> > GetAllLanguages(bool showHidden = false, string storeId = "") { string key = string.Format(CacheKey.LANGUAGES_ALL_KEY, showHidden); var languages = await _cacheBase.GetAsync(key, async() => { var query = from p in _languageRepository.Table select p; if (!showHidden) { query = query.Where(l => l.Published); } query = query.OrderBy(l => l.DisplayOrder); return(await Task.FromResult(query.ToList())); }); //store acl if (!string.IsNullOrWhiteSpace(storeId)) { languages = languages .Where(l => l.Stores.Contains(storeId) || !l.LimitedToStores) .ToList(); } return(languages); }
/// <summary> /// Gets all countries /// </summary> /// <param name="languageId">Language identifier.</param> /// <param name="storeId">Store ident</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Countries</returns> public virtual async Task <IList <Country> > GetAllCountries(string languageId = "", string storeId = "", bool showHidden = false) { string key = string.Format(CacheKey.COUNTRIES_ALL_KEY, languageId, showHidden); return(await _cacheBase.GetAsync(key, async() => { var query = from p in _countryRepository.Table select p; if (!showHidden) { query = query.Where(c => c.Published); } if (!showHidden && !CommonHelper.IgnoreStoreLimitations && string.IsNullOrEmpty(storeId)) { //Store acl query = from p in query where !p.LimitedToStores || p.Stores.Contains(storeId) select p; } var countries = await Task.FromResult(query.OrderBy(x => x.DisplayOrder).ThenBy(x => x.Name).ToList()); if (!string.IsNullOrEmpty(languageId)) { countries = countries .OrderBy(c => c.DisplayOrder) .ThenBy(c => c.GetTranslation(x => x.Name, languageId)) .ToList(); } return countries; })); }
/// <summary> /// Gets all countries /// </summary> /// <param name="languageId">Language identifier. It's used to sort countries by localized names (if specified); pass 0 to skip it</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Countries</returns> public virtual async Task <IList <Country> > GetAllCountries(string languageId = "", bool showHidden = false) { string key = string.Format(CacheKey.COUNTRIES_ALL_KEY, languageId, showHidden); return(await _cacheBase.GetAsync(key, async() => { var builder = Builders <Country> .Filter; var filter = builder.Empty; if (!showHidden) { filter = filter & builder.Where(c => c.Published); } if (!showHidden && !_catalogSettings.IgnoreStoreLimitations) { //Store mapping var currentStoreId = new List <string> { _storeContext.CurrentStore.Id }; filter = filter & (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores)); } var countries = await _countryRepository.Collection.Find(filter).SortBy(x => x.DisplayOrder).ThenBy(x => x.Name).ToListAsync(); if (!string.IsNullOrEmpty(languageId)) { //we should sort countries by localized names when they have the same display order countries = countries .OrderBy(c => c.DisplayOrder) .ThenBy(c => c.GetLocalized(x => x.Name, languageId)) .ToList(); } return countries; })); }
public virtual async Task <IActionResult> ArticlesByCategory(string categoryId) { if (!_knowledgebaseSettings.Enabled) { return(RedirectToRoute("HomePage")); } var category = await _knowledgebaseService.GetPublicKnowledgebaseCategory(categoryId); if (category == null) { return(RedirectToAction("List")); } var model = new KnowledgebaseHomePageModel(); var articles = await _knowledgebaseService.GetPublicKnowledgebaseArticlesByCategory(categoryId); var allCategories = _knowledgebaseService.GetPublicKnowledgebaseCategories(); articles.ForEach(x => model.Items.Add(new KnowledgebaseItemModel { Name = x.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id), Id = x.Id, SeName = x.GetTranslation(y => y.SeName, _workContext.WorkingLanguage.Id), IsArticle = true })); //display "edit" (manage) link var customer = _workContext.CurrentCustomer; if (await _permissionService.Authorize(StandardPermission.AccessAdminPanel, customer) && await _permissionService.Authorize(StandardPermission.ManageKnowledgebase, customer)) { DisplayEditLink(Url.Action("EditCategory", "Knowledgebase", new { id = categoryId, area = "Admin" })); } model.CurrentCategoryId = categoryId; model.CurrentCategoryDescription = category.GetTranslation(y => y.Description, _workContext.WorkingLanguage.Id); model.CurrentCategoryMetaDescription = category.GetTranslation(y => y.MetaDescription, _workContext.WorkingLanguage.Id); model.CurrentCategoryMetaKeywords = category.GetTranslation(y => y.MetaKeywords, _workContext.WorkingLanguage.Id); model.CurrentCategoryMetaTitle = category.GetTranslation(y => y.MetaTitle, _workContext.WorkingLanguage.Id); model.CurrentCategoryName = category.GetTranslation(y => y.Name, _workContext.WorkingLanguage.Id); model.CurrentCategorySeName = category.GetTranslation(y => y.SeName, _workContext.WorkingLanguage.Id); string breadcrumbCacheKey = string.Format(CacheKeyConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY, category.Id, string.Join(",", _workContext.CurrentCustomer.GetCustomerGroupIds()), _workContext.CurrentStore.Id, _workContext.WorkingLanguage.Id); model.CategoryBreadcrumb = await _cacheBase.GetAsync(breadcrumbCacheKey, async() => (await category.GetCategoryBreadCrumb(_knowledgebaseService, _aclService, _workContext)) .Select(catBr => new KnowledgebaseCategoryModel { Id = catBr.Id, Name = catBr.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id), SeName = catBr.GetSeName(_workContext.WorkingLanguage.Id) }) .ToList() ); return(View("List", model)); }
/// <summary> /// Gets a message template /// </summary> /// <param name="messageTemplateName">Message template name</param> /// <param name="storeId">Store identifier</param> /// <returns>Message template</returns> public virtual async Task <MessageTemplate> GetMessageTemplateByName(string messageTemplateName, string storeId) { if (string.IsNullOrWhiteSpace(messageTemplateName)) { throw new ArgumentException("messageTemplateName"); } string key = string.Format(CacheKey.MESSAGETEMPLATES_BY_NAME_KEY, messageTemplateName, storeId); return(await _cacheBase.GetAsync(key, async() => { var query = _messageTemplateRepository.Table; query = query.Where(t => t.Name == messageTemplateName); query = query.OrderBy(t => t.Id); var templates = await query.ToListAsync(); //store mapping if (!String.IsNullOrEmpty(storeId)) { templates = templates .Where(t => _storeMappingService.Authorize(t, storeId)) .ToList(); } return templates.FirstOrDefault(); })); }
/// <summary> /// Gets all countries /// </summary> /// <param name="languageId">Language identifier.</param> /// <param name="storeId">Store ident</param> /// <param name="showHidden">A value indicating whether to show hidden records</param> /// <returns>Countries</returns> public virtual async Task <IList <Country> > GetAllCountries(string languageId = "", string storeId = "", bool showHidden = false) { string key = string.Format(CacheKey.COUNTRIES_ALL_KEY, languageId, showHidden); return(await _cacheBase.GetAsync(key, async() => { var builder = Builders <Country> .Filter; var filter = builder.Empty; if (!showHidden) { filter &= builder.Where(c => c.Published); } if (!showHidden && !CommonHelper.IgnoreStoreLimitations && string.IsNullOrEmpty(storeId)) { //Store acl filter &= (builder.AnyIn(x => x.Stores, new List <string> { storeId }) | builder.Where(x => !x.LimitedToStores)); } var countries = await _countryRepository.Collection.Find(filter).SortBy(x => x.DisplayOrder).ThenBy(x => x.Name).ToListAsync(); if (!string.IsNullOrEmpty(languageId)) { countries = countries .OrderBy(c => c.DisplayOrder) .ThenBy(c => c.GetTranslation(x => x.Name, languageId)) .ToList(); } return countries; })); }
/// <summary> /// Gets all checkout attributes /// </summary> /// <param name="storeId">Store identifier</param> /// <param name="excludeShippableAttributes">A value indicating whether we should exlude shippable attributes</param> /// <returns>Checkout attributes</returns> public virtual async Task <IList <CheckoutAttribute> > GetAllCheckoutAttributes(string storeId = "", bool excludeShippableAttributes = false, bool ignorAcl = false) { string key = string.Format(CacheKey.CHECKOUTATTRIBUTES_ALL_KEY, storeId, excludeShippableAttributes, ignorAcl); return(await _cacheBase.GetAsync(key, () => { var query = _checkoutAttributeRepository.Table; query = query.OrderBy(c => c.DisplayOrder); if ((!String.IsNullOrEmpty(storeId) && !_catalogSettings.IgnoreStoreLimitations) || (!ignorAcl && !_catalogSettings.IgnoreAcl)) { if (!ignorAcl && !_catalogSettings.IgnoreAcl) { var allowedCustomerRolesIds = _workContext.CurrentCustomer.GetCustomerRoleIds(); query = from p in query where !p.SubjectToAcl || allowedCustomerRolesIds.Any(x => p.CustomerRoles.Contains(x)) select p; } //Store mapping if (!String.IsNullOrEmpty(storeId) && !_catalogSettings.IgnoreStoreLimitations) { query = from p in query where !p.LimitedToStores || p.Stores.Contains(storeId) select p; } } if (excludeShippableAttributes) { query = query.Where(x => !x.ShippableProductRequired); } return query.ToListAsync(); })); }
/// <summary> /// Gets an email account by identifier /// </summary> /// <param name="emailAccountId">The email account identifier</param> /// <returns>Email account</returns> public virtual async Task <EmailAccount> GetEmailAccountById(string emailAccountId) { string key = string.Format(CacheKey.EMAILACCOUNT_BY_ID_KEY, emailAccountId); return(await _cacheBase.GetAsync(key, () => { return _emailAccountRepository.GetByIdAsync(emailAccountId); })); }
/// <summary> /// Gets all stores /// </summary> /// <returns>Stores</returns> public virtual async Task <IList <Store> > GetAllStores() { if (_allStores == null) { _allStores = await _cacheBase.GetAsync(CacheKey.STORES_ALL_KEY, () => { return(_storeRepository.Collection.Find(new BsonDocument()).SortBy(x => x.DisplayOrder).ToListAsync()); }); } return(_allStores); }
/// <summary> /// Gets all merchandise return actions /// </summary> /// <returns>Merchandise return actions</returns> public virtual async Task <IList <MerchandiseReturnAction> > GetAllMerchandiseReturnActions() { return(await _cacheBase.GetAsync(CacheKey.MERCHANDISE_RETURN_ACTIONS_ALL_KEY, async() => { var query = from rra in _merchandiseReturnActionRepository.Table orderby rra.DisplayOrder select rra; return await Task.FromResult(query.ToList()); })); }
/// <summary> /// Gets all product layouts /// </summary> /// <returns>Product layouts</returns> public virtual async Task <IList <ProductLayout> > GetAllProductLayouts() { return(await _cacheBase.GetAsync(CacheKey.PRODUCT_LAYOUT_ALL, () => { var query = from pt in _productLayoutRepository.Table orderby pt.DisplayOrder select pt; return query.ToListAsync(); })); }
/// <summary> /// Gets all existing category layout /// </summary> /// <returns>Category layouts</returns> public virtual async Task <IList <CategoryLayout> > GetAllCategoryLayouts() { return(await _cacheBase.GetAsync(CacheKey.CATEGORY_LAYOUT_ALL, () => { var query = from pt in _categoryLayoutRepository.Table orderby pt.DisplayOrder select pt; return query.ToListAsync(); })); }
/// <summary> /// Gets all brand layouts /// </summary> /// <returns>Brand layouts</returns> public virtual async Task <IList <BrandLayout> > GetAllBrandLayouts() { return(await _cacheBase.GetAsync(CacheKey.BRAND_LAYOUT_ALL, async() => { var query = from pt in _brandLayoutRepository.Table orderby pt.DisplayOrder select pt; return await Task.FromResult(query.ToList()); })); }
/// <summary> /// Gets all cached URL Entity /// </summary> /// <returns>cached URL Entities</returns> protected virtual async Task <IList <EntityUrl> > GetAllUrlEntityCached() { //cache string key = string.Format(CacheKey.URLEntity_ALL_KEY); return(await _cacheBase.GetAsync(key, async() => { return await Task.FromResult(_urlEntityRepository.Table.ToList()); })); }
/// <summary> /// Gets all activity log types (to caching) /// </summary> /// <returns>Activity log types</returns> protected virtual async Task <IList <ActivityLogType> > GetAllActivityTypesCached() { //cache string key = string.Format(CacheKey.ACTIVITYTYPE_ALL_KEY); return(await _cacheBase.GetAsync(key, async() => { return await GetAllActivityTypes(); })); }
/// <summary> /// Gets all stores /// </summary> /// <returns>Stores</returns> public virtual async Task <IList <Store> > GetAllStores() { if (_allStores == null) { _allStores = await _cacheBase.GetAsync(CacheKey.STORES_ALL_KEY, async() => { return(await Task.FromResult(_storeRepository.Table.OrderBy(x => x.DisplayOrder).ToList())); }); } return(_allStores); }
/// <summary> /// Gets a state/province /// </summary> /// <param name="stateProvinceId">The state/province identifier</param> /// <returns>State/province</returns> public virtual async Task <StateProvince> GetStateProvinceById(string stateProvinceId) { if (string.IsNullOrEmpty(stateProvinceId)) { return(null); } var key = string.Format(CacheKey.STATEPROVINCES_BY_KEY, stateProvinceId); return(await _cacheBase.GetAsync(key, () => _stateProvinceRepository.GetByIdAsync(stateProvinceId))); }
/// <summary> /// Gets all product attributes /// </summary> /// <param name="pageIndex">Page index</param> /// <param name="pageSize">Page size</param> /// <returns>Product attributes</returns> public virtual async Task <IPagedList <ProductAttribute> > GetAllProductAttributes(int pageIndex = 0, int pageSize = int.MaxValue) { string key = string.Format(CacheKey.PRODUCTATTRIBUTES_ALL_KEY, pageIndex, pageSize); return(await _cacheBase.GetAsync(key, () => { var query = from pa in _productAttributeRepository.Table orderby pa.Name select pa; return Task.FromResult(new PagedList <ProductAttribute>(query, pageIndex, pageSize)); })); }
/// <summary> /// Gets all customer attributes /// </summary> /// <returns>Customer attributes</returns> public virtual async Task <IList <CustomerAttribute> > GetAllCustomerAttributes() { string key = CacheKey.CUSTOMERATTRIBUTES_ALL_KEY; return(await _cacheBase.GetAsync(key, () => { var query = from ca in _customerAttributeRepository.Table orderby ca.DisplayOrder select ca; return query.ToListAsync(); })); }
/// <summary> /// Gets all address attributes /// </summary> /// <returns>Address attributes</returns> public virtual async Task <IList <AddressAttribute> > GetAllAddressAttributes() { string key = CacheKey.ADDRESSATTRIBUTES_ALL_KEY; return(await _cacheBase.GetAsync(key, async() => { var query = from aa in _addressAttributeRepository.Table orderby aa.DisplayOrder select aa; return await Task.FromResult(query.ToList()); })); }
/// <summary> /// Gets all tax categories /// </summary> /// <returns>Tax categories</returns> public virtual async Task <IList <TaxCategory> > GetAllTaxCategories() { string key = string.Format(CacheKey.TAXCATEGORIES_ALL_KEY); return(await _cacheBase.GetAsync(key, () => { var query = from tc in _taxCategoryRepository.Table orderby tc.DisplayOrder select tc; return query.ToListAsync(); })); }
/// <summary> /// Get a picture URL /// </summary> /// <param name="pictureId">Picture identifier</param> /// <param name="targetSize">The target picture size (longest side)</param> /// <param name="showDefaultPicture">A value indicating whether the default picture is shown</param> /// <param name="storeLocation">Store location URL; null to use determine the current store location automatically</param> /// <returns>Picture URL</returns> public virtual async Task <string> GetPictureUrl(string pictureId, int targetSize = 0, bool showDefaultPicture = true, string storeLocation = null) { var pictureKey = string.Format(CacheKey.PICTURE_BY_KEY, pictureId, _workContext.CurrentStore?.Id, targetSize, showDefaultPicture, storeLocation); return(await _cacheBase.GetAsync(pictureKey, async() => { var picture = await GetPictureById(pictureId); return await GetPictureUrl(picture, targetSize, showDefaultPicture, storeLocation); })); }
/// <summary> /// Gets a customer group /// </summary> /// <param name="customerGroupId">Customer group identifier</param> /// <returns>Customer group</returns> public virtual Task <CustomerGroup> GetCustomerGroupById(string customerGroupId) { if (string.IsNullOrWhiteSpace(customerGroupId)) { return(Task.FromResult <CustomerGroup>(null)); } string key = string.Format(CacheKey.CUSTOMERGROUPS_BY_KEY, customerGroupId); return(_cacheBase.GetAsync(key, () => { return _customerGroupRepository.GetByIdAsync(customerGroupId); })); }
/// <summary> /// Gets knowledgebase category /// </summary> /// <param name="id"></param> /// <returns>knowledgebase category</returns> public virtual async Task <KnowledgebaseCategory> GetPublicKnowledgebaseCategory(string id) { string key = string.Format(CacheKey.KNOWLEDGEBASE_CATEGORY_BY_ID, id, _workContext.CurrentCustomer.GetCustomerGroupIds(), _workContext.CurrentStore.Id); return(await _cacheBase.GetAsync(key, async() => { var query = from p in _knowledgebaseCategoryRepository.Table select p; query = query.Where(x => x.Published); query = query.Where(x => x.Id == id); if (!CommonHelper.IgnoreAcl) { //Limited to customer groups rules var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds(); query = from p in query where !p.LimitedToGroups || allowedCustomerGroupsIds.Any(x => p.CustomerGroups.Contains(x)) select p; } if (!CommonHelper.IgnoreStoreLimitations) { //Store acl query = from p in query where !p.LimitedToStores || p.Stores.Contains(_workContext.CurrentStore.Id) select p; } var toReturn = await Task.FromResult(query.FirstOrDefault()); return toReturn; })); }
/// <summary> /// Gets knowledgebase category /// </summary> /// <param name="id"></param> /// <returns>knowledgebase category</returns> public virtual async Task <KnowledgebaseCategory> GetPublicKnowledgebaseCategory(string id) { string key = string.Format(CacheKey.KNOWLEDGEBASE_CATEGORY_BY_ID, id, _workContext.CurrentCustomer.GetCustomerGroupIds(), _workContext.CurrentStore.Id); return(await _cacheBase.GetAsync(key, () => { var builder = Builders <KnowledgebaseCategory> .Filter; var filter = FilterDefinition <KnowledgebaseCategory> .Empty; filter &= builder.Where(x => x.Published); filter &= builder.Where(x => x.Id == id); if (!CommonHelper.IgnoreAcl) { var allowedCustomerGroupsIds = _workContext.CurrentCustomer.GetCustomerGroupIds(); filter &= (builder.AnyIn(x => x.CustomerGroups, allowedCustomerGroupsIds) | builder.Where(x => !x.LimitedToGroups)); } if (!CommonHelper.IgnoreStoreLimitations) { //Store acl var currentStoreId = new List <string> { _workContext.CurrentStore.Id }; filter &= (builder.AnyIn(x => x.Stores, currentStoreId) | builder.Where(x => !x.LimitedToStores)); } var toReturn = _knowledgebaseCategoryRepository.Collection.Find(filter); return toReturn.FirstOrDefaultAsync(); })); }
/// <summary> /// Authorize permission /// </summary> /// <param name="permissionSystemName">Permission system name</param> /// <param name="customerGroup">Customer group</param> /// <returns>true - authorized; otherwise, false</returns> protected virtual async Task <bool> Authorize(string permissionSystemName, CustomerGroup customerGroup) { if (string.IsNullOrEmpty(permissionSystemName)) { return(false); } string key = string.Format(CacheKey.PERMISSIONS_ALLOWED_KEY, customerGroup.Id, permissionSystemName); return(await _cacheBase.GetAsync(key, async() => { var permissionRecord = await Task.FromResult(_permissionRepository.Table.Where(x => x.SystemName == permissionSystemName).FirstOrDefault()); return permissionRecord?.CustomerGroups.Contains(customerGroup.Id) ?? false; })); }
public async Task <IList <CategoryModel> > Handle(GetHomepageCategory request, CancellationToken cancellationToken) { string categoriesCacheKey = string.Format(CacheKeyConst.CATEGORY_HOMEPAGE_KEY, string.Join(",", request.Customer.GetCustomerGroupIds()), request.Store.Id, request.Language.Id); var model = await _cacheBase.GetAsync(categoriesCacheKey, async() => { var cat = new List <CategoryModel>(); foreach (var x in (await _categoryService.GetAllCategoriesDisplayedOnHomePage())) { var catModel = x.ToModel(request.Language); //prepare picture model catModel.PictureModel = new PictureModel { Id = x.PictureId, FullSizeImageUrl = await _pictureService.GetPictureUrl(x.PictureId), ImageUrl = await _pictureService.GetPictureUrl(x.PictureId, _mediaSettings.CategoryThumbPictureSize), Title = string.Format(_translationService.GetResource("Media.Category.ImageLinkTitleFormat"), catModel.Name), AlternateText = string.Format(_translationService.GetResource("Media.Category.ImageAlternateTextFormat"), catModel.Name) }; cat.Add(catModel); } return(cat); }); return(model); }
public async Task <ManufacturerNavigationModel> Handle(GetManufacturerNavigation request, CancellationToken cancellationToken) { string cacheKey = string.Format(ModelCacheEventConst.MANUFACTURER_NAVIGATION_MODEL_KEY, request.CurrentManufacturerId, request.Language.Id, string.Join(",", request.Customer.GetCustomerRoleIds()), request.Store.Id); var cacheModel = await _cacheBase.GetAsync(cacheKey, async() => { var currentManufacturer = await _manufacturerService.GetManufacturerById(request.CurrentManufacturerId); var manufacturers = await _manufacturerService.GetAllManufacturers(pageSize: _catalogSettings.ManufacturersBlockItemsToDisplay, storeId: request.Store.Id); var model = new ManufacturerNavigationModel { TotalManufacturers = manufacturers.TotalCount }; foreach (var manufacturer in manufacturers) { var modelMan = new ManufacturerBriefInfoModel { Id = manufacturer.Id, Name = manufacturer.GetLocalized(x => x.Name, request.Language.Id), Icon = manufacturer.Icon, SeName = manufacturer.GetSeName(request.Language.Id), IsActive = currentManufacturer != null && currentManufacturer.Id == manufacturer.Id, }; model.Manufacturers.Add(modelMan); } return(model); }); return(cacheModel); }
public async Task <BlogPostTagListModel> Handle(GetBlogPostTagList request, CancellationToken cancellationToken) { var cacheKey = string.Format(CacheKeyConst.BLOG_TAGS_MODEL_KEY, _workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id); var cachedModel = await _cacheBase.GetAsync(cacheKey, async() => { var model = new BlogPostTagListModel(); //get tags var tags = await _blogService.GetAllBlogPostTags(_workContext.CurrentStore.Id); tags = tags.OrderByDescending(x => x.BlogPostCount) .Take(_blogSettings.NumberOfTags) .ToList(); //sorting tags = tags.OrderBy(x => x.Name).ToList(); foreach (var tag in tags) { model.Tags.Add(new BlogPostTagModel { Name = tag.Name, BlogPostCount = tag.BlogPostCount }); } return(model); }); return(cachedModel); }