public void SetCobrand(Cobrand cobrand, bool isMain = true) { if (AccountCobrands == null) { AccountCobrands = new List <AccountCobrand>(); } // first remove any old cobrands while (AccountCobrands.Any()) { AccountCobrands.Remove(AccountCobrands.FirstOrDefault()); } CacheHelper.RemoveItemFromCache(CacheHelperKeys.GetCacheKeyForAccountSetting_ForAccount(ID)); if (cobrand != null) // null means remove cobrand { AccountSettings.EmphasiseProperty = cobrand.EmphasiseProperty; var accountCobrand = new AccountCobrand { Cobrand = cobrand, IsMain = isMain, IsCurrentClient = true }; AccountCobrands.Add(accountCobrand); } CacheHelper.RemoveItemFromCache(CacheHelperKeys.GetCacheKeyForCobrandId_ForAccount(ID)); CacheHelper.RemoveItemFromCache(CacheHelperKeys.GetCacheKeyForCobrandDTOId_ForAccount(ID), _useLocalCacheForCobrand); CacheHelper.RemoveItemFromCache(CacheHelperKeys.GetCacheKeyFor_ActiveCobrandBranchID_ForAccount(ID)); }
public AccountSetting GetAccountSettingCached() { var cachekey = CacheHelperKeys.GetCacheKeyForAccountSetting_ForAccount(ID); AccountSetting accountSetting = (AccountSetting)CacheHelper.GetItemFromCache(cachekey); if (accountSetting == null) { accountSetting = AccountSettings; CacheHelper.AddItemToCache(cachekey, accountSetting); } return(accountSetting); }
public static List <Category> GetCategoryListFromCache(CacheHelperKeys cacheKey = CacheHelperKeys.constCategoryList) { List <Category> result = WebCache.Get(cacheKey.ToString()) as List <Category>; if (result == null) { CategoryManager categoryManager = new CategoryManager(); result = categoryManager.List(x => x.IsDeleted == false); WebCache.Set(cacheKey.ToString(), result, 20, true); } return(result); }
public static void RemoveCache(CacheHelperKeys cacheKey = CacheHelperKeys.constCategoryList) { WebCache.Remove(cacheKey.ToString()); }