public static void RefreshUserRoleMappings() { MappingService service = new MappingService(); var mappings = service.GetUserRoleMapping().Result; if (mappings == null) { mappings = Enumerable.Empty <UserRoleMapping>(); } lock (lockobject) { CacheHelper.Remove("UserRoleMapping"); CacheHelper.Insert("UserRoleMapping", mappings); } }
public static IEnumerable <UserRoleMapping> GetUserRoleMappings() { var userRoleMappings = (IEnumerable <UserRoleMapping>)CacheHelper.Get("UserRoleMapping", () => { MappingService service = new MappingService(); var mappings = service.GetUserRoleMapping().Result; if (mappings == null) { mappings = Enumerable.Empty <UserRoleMapping>(); } lock (lockobject) { CacheHelper.Insert("UserRoleMapping", mappings); } }); return(userRoleMappings); }