public Task <string> GetSiteIdAsync(IDictionary <string, string> data, string masterDomainId) { var getSiteId = new GetSiteId(); getSiteId.Data = data; getSiteId.MasterDomainId = masterDomainId; return(_dataFactory.CacheRepository.GetSiteIdFromKeyAsync(getSiteId, CacheRepository.CacheRouteKey)); }
public async Task UpdateCacheAsync(string siteId) { await _dataFactory.CacheRepository.DeleteAsync(siteId); var itemDataModel = await _dataFactory.ItemRepository.GetItemAsync(null, siteId); var siteDataModel = (SiteBusinessModel)itemDataModel.Data; var getSiteId = new GetSiteId(); getSiteId.MasterDomainId = siteDataModel.MasterDomainId; getSiteId.Data = new Dictionary <string, string>(); getSiteId.Data.Add("site", UrlHelper.NormalizeTextForUrl(siteDataModel.Name)); IList <CacheItem> cacheItems = new List <CacheItem>(3); var key = JsonConvert.SerializeObject(getSiteId); var site = new CacheItem { SiteId = siteId, Type = CacheRepository.CacheRouteKey, Key = key, Value = JsonConvert.SerializeObject(await GetRootMetadataAsync(siteId)), CreateDate = DateTime.Now }; cacheItems.Add(site); var siteSeo = new CacheItem { SiteId = siteId, Type = CacheRepository.CacheSeoKey, Key = "Seo", Value = JsonConvert.SerializeObject(false), CreateDate = DateTime.Now }; cacheItems.Add(siteSeo); await _dataFactory.CacheRepository.SaveAsync(cacheItems); }
public async Task <IEnumerable <CacheItem> > CacheItemsAsync(string masterDomainId = "") { var sites = new List <CacheItem>(); var siteRepository = _dataFactory.ItemRepository; var _siteDataModels = await siteRepository.GetItemsAsync(null, new ItemFilters { Module = "Site" }); foreach (var itemDataModel in _siteDataModels) { var siteDataModel = (SiteBusinessModel)itemDataModel.Data; if (string.IsNullOrEmpty(masterDomainId) || siteDataModel.MasterDomainId == masterDomainId) { var siteId = itemDataModel.Id.ToString(CultureInfo.InvariantCulture); var getSiteId = new GetSiteId(); getSiteId.MasterDomainId = string.IsNullOrEmpty(masterDomainId) ? siteDataModel.MasterDomainId: masterDomainId; getSiteId.Data = new Dictionary <string, string>(); getSiteId.Data.Add("site", UrlHelper.NormalizeTextForUrl(siteDataModel.Name)); if (!string.IsNullOrEmpty(siteDataModel.Domain)) { getSiteId.Data.Add("domain", UrlHelper.NormalizeTextForUrl(siteDataModel.Domain)); } var key = JsonConvert.SerializeObject(getSiteId); var site = new CacheItem { SiteId = siteId, Type = CacheRepository.CacheRouteKey, Key = key, Value = JsonConvert.SerializeObject(await GetRootMetadataAsync(siteId)), CreateDate = DateTime.Now }; sites.Add(site); var sitePrivate = new CacheItem { SiteId = siteId, Type = CacheRepository.CacheRouteKey, Key = key, Value = JsonConvert.SerializeObject(await GetRootMetadataAsync(siteId, "PrivateMenuItems")), CreateDate = DateTime.Now }; sites.Add(sitePrivate); await _dataFactory.CacheRepository.SaveAsync(site); var siteSeo = new CacheItem { SiteId = siteId, Type = CacheRepository.CacheSeoKey, Key = "Seo", Value = JsonConvert.SerializeObject(false), CreateDate = DateTime.Now }; await _dataFactory.CacheRepository.SaveAsync(siteSeo); } } return(sites); }