Beispiel #1
0
        public async Task <T> RetrieveOAuth <T>(string username) where T : IOAuthModel, new()
        {
            var def     = new T();
            var service = def.GetServiceName();

            //Get all registered integrations for user
            var oauths = await db.GetMultipleByUsername(username);

            return(JsonConvert.DeserializeObject <T>(JsonConvert.SerializeObject(oauths.FirstOrDefault(x => x.Service == service))));
        }
        public async Task <DropshipOverview> GetOverview(string username)
        {
            var accountTask      = GetAccount(username);
            var productsTask     = dbItems.GetMultipleByUsername(username);
            var integrationsTask = dbOAuth.GetMultipleByUsername(username);
            //var ordersTask = GetOrders(username);

            var account      = await accountTask;
            var items        = await productsTask;
            var integrations = await integrationsTask;

            var dropshipOverview = new DropshipOverview()
            {
                Account          = account,
                IntegrationCount = integrations.Length,
                ProductCount     = items.Length
            };

            return(dropshipOverview);
        }
Beispiel #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);
            }
        }