Exemplo n.º 1
0
 async Task cacheServices(WebSearchService[] services)
 {
     foreach (WebSearchService service in services)
     {
         var serviceKey = service.ServiceModel.GetRedisKey();
         await cache.StoreString(serviceKey, JsonConvert.SerializeObject(service.ServiceModel));
     }
 }
        public static async Task SetSearchServices(WebSearchService[] services, IApplicationCache cache)
        {
            foreach (var model in services)
            {
                var key = model.ServiceModel.GetRedisKey();

                await cache.StoreString(key, JsonConvert.SerializeObject(model.ServiceModel));
            }
        }
Exemplo n.º 3
0
        async Task <OAuthShopifyModel> GetCredentials(string username)
        {
            var key = $"OAuth:Shopify:{username}";

            if (await cache.Exists(key))
            {
                return(JsonConvert.DeserializeObject <OAuthShopifyModel>(await cache.GetString(key)));
            }

            var integrations = await oauthDb.GetMultipleByUsername(username);

            var shopifyIntegration = integrations.FirstOrDefault(x => x.Service == "Shopify");

            if (shopifyIntegration != null)
            {
                await cache.StoreString(key, JsonConvert.SerializeObject(shopifyIntegration));

                return(JsonConvert.DeserializeObject <OAuthShopifyModel>(JsonConvert.SerializeObject(shopifyIntegration)));
            }
            else
            {
                return(null);
            }
        }