Пример #1
0
        public async Task <IEnumerable <Location> > GetLocations(Subscription subscription)
        {
            List <Location> locations = new List <Location>();

            try
            {
                SubscriptionClient rdfeClient = GetRdfeSubscriptionClient();
                var webspaces = rdfeClient.GetWebSpaces(subscription.Id);

                foreach (var webspace in webspaces)
                {
                    locations.Add(new Location()
                    {
                        Id          = webspace.Name,
                        Name        = webspace.GeoRegion,
                        DisplayName = webspace.GeoRegion
                    });
                }
            }
            catch
            {
                // Return a fixed list
                locations.AddRange(new Location[]
                {
                    new Location()
                    {
                        Id          = "USAAnywhere",
                        Name        = "USA Anywhere",
                        DisplayName = "USA Anywhere"
                    }
                });
            }

            // Make async call happy
            await Task.Delay(0);

            return(locations.OrderBy(sub => sub.DisplayName));
        }