Ejemplo n.º 1
0
        public async Task TestGetManagedSites()
        {
            var filter = new ManagedSiteFilter();
            var result = await _client.GetManagedSites(filter);

            Assert.IsNotNull(result, $"Fetched {result.Count} managed sites");
        }
Ejemplo n.º 2
0
        public async Task <List <ManagedSite> > GetManagedSites(ManagedSiteFilter filter = null, bool reloadAll = true)
        {
            // Don't reload settings unless we need to or we are unsure if any items have changed
            if (!ManagedSitesCache.Any() || IsSingleInstanceMode == false || reloadAll)
            {
                await LoadAllManagedItems();
            }

            // filter and convert dictionary to list TODO: use db instead of in memory filter?
            var items = ManagedSitesCache.Values.AsEnumerable();

            if (filter != null)
            {
                if (!String.IsNullOrEmpty(filter.Keyword))
                {
                    items = items.Where(i => i.Name.ToLowerInvariant().Contains(filter.Keyword.ToLowerInvariant()));
                }

                //TODO: IncludeOnlyNextAutoRenew
                if (filter.MaxResults > 0)
                {
                    items = items.Take(filter.MaxResults);
                }
            }
            return(new List <ManagedSite>(items));
        }
Ejemplo n.º 3
0
        public async Task TestGetManagedSite()
        {
            //get full list
            var filter = new ManagedSiteFilter {
                MaxResults = 10
            };
            var results = await _client.GetManagedSites(filter);

            Assert.IsTrue(results.Count > 0, "Got one or more managed sites");

            //attempt to get single item
            var site = await _client.GetManagedSite(results[0].Id);

            Assert.IsNotNull(site, $"Fetched single managed site details");
        }
Ejemplo n.º 4
0
        public async Task <List <ManagedSite> > GetManagedSites(ManagedSiteFilter filter)
        {
            var response = await PostAsync("managedsites/search/", filter);

            var sites = await response.Content.ReadAsStringAsync();

            var serializer = new JsonSerializer();

            using (StreamReader sr = new StreamReader(await response.Content.ReadAsStreamAsync()))
                using (JsonTextReader reader = new JsonTextReader(sr))
                {
                    var managedSiteList = serializer.Deserialize <List <ManagedSite> >(reader);
                    foreach (var s in managedSiteList)
                    {
                        s.IsChanged = false;
                    }
                    return(managedSiteList);
                }
        }
Ejemplo n.º 5
0
        public async Task <List <ManagedSite> > Search(ManagedSiteFilter filter)
        {
            DebugLog();

            return(await _certifyManager.GetManagedSites(filter));
        }