private async Task <List <Partnership> > getPartnerShipsList(string uri)
        {
            List <Partnership> partnerShips = (List <Partnership>)CacheManager.GetCacheItem("partnership_list");

            if (partnerShips == null || partnerShips.Count == 0)
            {
                partnerShips = await getList <Partnership>(uri);

                CacheManager.AddCacheItem("partnership_list", partnerShips, 5);
            }

            return(partnerShips);
        }
        public async Task retrieveApiCatalog(string endpoint)
        {
            apiCataloglinks = (Dictionary <String, Link>)CacheManager.GetCacheItem("api_catalog_links");

            if (apiCataloglinks == null)
            {
                var response = await SecuredApiGetRequest(endpoint);

                ApiCatalog apiCatalog = await PartnershipWorkflow.DeserialiseAsync <ApiCatalog>(response.Content);

                apiCataloglinks = OAuthWorkFlow.linksFrom(apiCatalog);
                CacheManager.AddCacheItem("api_catalog_links", apiCataloglinks, 60 * 6);
            }
        }
        public async Task <Resource> getResourceFromCache(string resourceLink)
        {
            Resource r = (Resource)CacheManager.GetCacheItem(resourceLink);

            if (r == null)
            {
                Logger.Log("RESOURCE", "getResourceFromCache");

                var response = await SecuredApiGetRequest(resourceLink);

                r = await PartnershipWorkflow.DeserialiseAsync <Resource>(response.Content);

                Logger.Log(response);
                CacheManager.AddCacheItem(resourceLink, r, 5);
            }
            return(r);
        }
        public async Task <User> getCurrentUser(bool fillChildOrgs)
        {
            string cacheKey    = "current_user_childorgs_" + fillChildOrgs.ToString();
            User   currentUser = (User)CacheManager.GetCacheItem(cacheKey);

            if (currentUser == null)
            {
                var response = await SecuredApiGetRequest(apiCataloglinks["currentUser"].uri);

                currentUser = await PartnershipWorkflow.DeserialiseAsync <User>(response.Content);

                if (fillChildOrgs)
                {
                    currentUser.Organizations = await getList <Organization>(OAuthWorkFlow.linksFrom(currentUser)["organizations"].uri);
                }
                CacheManager.AddCacheItem(cacheKey, currentUser, 30);
            }
            return(currentUser);
        }
        private async Task <Organization> getOrganization(Link orgLink, bool allowFetchFromCache)
        {
            Organization org = null;

            if (allowFetchFromCache)
            {
                org = (Organization)CacheManager.GetCacheItem(orgLink.uri);
            }

            if (org == null)
            {
                Logger.Log("RESOURCE", "getOrganization");
                var response = await SecuredApiGetRequest(orgLink.uri);

                Logger.Log(response);
                org = await PartnershipWorkflow.DeserialiseAsync <Organization>(response.Content);

                CacheManager.AddCacheItem(orgLink.uri, org, 5);
            }

            return(org);
        }
        public IList <T> GetItems()
        {
            var list = _cacheManager.Get <IList <T> >(_key);

            if (list != null)
            {
                return(list);
            }

            lock (_lock)
            {
                if (_cacheManager.Get <IList <T> >(_cacheKey) != null)
                {
                    return;
                }

                var items = _getMethod.Invoke();
                _cacheManager.AddCacheItem(_cacheKey, items);
            }

            return(_cacheManager.Get <IList <T> >(_key));
        }