/// <summary> /// Selects the map by id. /// </summary> /// <param name="portalSettingsId">The portal settings id.</param> /// <param name="fromCache">if set to <c>true</c> [from cache].</param> /// <returns></returns> public PortalSettingsMap SelectMapById(Guid portalSettingsId, bool fromCache) { var key = string.Format("{0}_SelectMapById_{1}", CacheKey, portalSettingsId); var cacheItem = fromCache ? LeadForceCache.Cache[key] : null; if (cacheItem != null) { return((PortalSettingsMap)cacheItem); } PortalSettingsMap portalSettings = _dataContext.tbl_PortalSettings.Select(ps => new PortalSettingsMap() { ID = ps.ID, SiteID = ps.SiteID, Domain = ps.Domain, Logo = ps.Logo, CompanyMessage = ps.CompanyMessage, HeaderTemplate = ps.HeaderTemplate, Title = ps.Title, WelcomeMessage = ps.WelcomeMessage, MainMenuBackground = ps.MainMenuBackground, BlockTitleBackground = ps.BlockTitleBackground }).SingleOrDefault(c => c.ID == portalSettingsId); LeadForceCache.CacheData(key, portalSettings, 60); return(portalSettings); }
/// <summary> /// Selects the by domain. /// </summary> /// <param name="domain">The domain.</param> /// <param name="fromCache">if set to <c>true</c> [from cache].</param> /// <returns></returns> public PortalSettingsMap SelectMapByDomain(string domain, bool fromCache = false) { var key = string.Format("{0}_SelectMapByDomain_{1}", CacheKey, domain); var cacheItem = fromCache ? LeadForceCache.Cache[key] : null; if (cacheItem != null) { return((PortalSettingsMap)cacheItem); } PortalSettingsMap portalSettings = null; portalSettings = _dataContext.tbl_PortalSettings.Select(ps => new PortalSettingsMap() { ID = ps.ID, SiteID = ps.SiteID, Domain = ps.Domain, Logo = ps.Logo, CompanyMessage = ps.CompanyMessage, HeaderTemplate = ps.HeaderTemplate, Title = ps.Title, WelcomeMessage = ps.WelcomeMessage }).FirstOrDefault(c => c.Domain.ToLower() == domain.ToLower()); LeadForceCache.CacheData(key, portalSettings, 300); return(portalSettings); }
/// <summary> /// Selects the by site id. /// </summary> /// <param name="siteId">The site id.</param> /// <param name="fromCache">if set to <c>true</c> [from cache].</param> /// <returns></returns> public PortalSettingsMap SelectMapBySiteId(Guid siteId, bool fromCache) { var key = string.Format("{0}_SelectMapBySiteId_{1}", CacheKey, siteId); var cacheItem = fromCache ? LeadForceCache.Cache[key] : null; if (cacheItem != null) { return((PortalSettingsMap)cacheItem); } var tblPortalSettings = _dataContext.tbl_PortalSettings.FirstOrDefault(c => c.SiteID == siteId && !string.IsNullOrEmpty(c.Domain)) ?? _dataContext.tbl_PortalSettings.FirstOrDefault(c => c.SiteID == siteId); PortalSettingsMap portalSettings = null; if (tblPortalSettings != null) { portalSettings = new PortalSettingsMap() { ID = tblPortalSettings.ID, SiteID = tblPortalSettings.SiteID, Domain = tblPortalSettings.Domain, Logo = tblPortalSettings.Logo, CompanyMessage = tblPortalSettings.CompanyMessage, HeaderTemplate = tblPortalSettings.HeaderTemplate, Title = tblPortalSettings.Title, WelcomeMessage = tblPortalSettings.WelcomeMessage, MainMenuBackground = tblPortalSettings.MainMenuBackground, BlockTitleBackground = tblPortalSettings.BlockTitleBackground } } ; LeadForceCache.CacheData(key, portalSettings, 60); return(portalSettings); }