ArcGISPortalViewer.Model.FavoritesService.GetFavoritesIds C# (CSharp) Method

GetFavoritesIds() public method

public GetFavoritesIds ( ) : List
return List
        public List<string> GetFavoritesIds()
        {
            var favorites = new List<string>();
            ApplicationDataContainer roamingSettings = ApplicationData.Current.RoamingSettings;
            if (roamingSettings.Values["FavoritesList"] != null)
            {
                var ids = roamingSettings.Values["FavoritesList"] as string[];
                favorites.AddRange(ids);
            }
            return favorites;
        }

Usage Example

        private async void PopulatePortalItemCollection(ObservableCollection<ArcGISPortalItem> portalCollection, PortalQuery portalQuery)
        {
            if (portalCollection == null || portalQuery == PortalQuery.MyGroups)
                return;

            FavoritesService currentFavoritesService = new FavoritesService();
            await currentFavoritesService.SetFavoritesCollection();

            SearchParameters sp = null;
            if (portalQuery == PortalQuery.Favorites)
                sp = SearchService.CreateSearchParameters("", portalQuery, 0, 20, currentFavoritesService.GetFavoritesIds());
            else
                sp = SearchService.CreateSearchParameters("", portalQuery);

            IsLoadingData = true;
            IList<ArcGISPortalItem> portalItems = await PortalService.CurrentPortalService.GetPortalItems(sp);

            if (portalItems != null)
            {
                portalCollection.Clear();

                foreach (ArcGISPortalItem pi in portalItems)
                {
                    portalCollection.Add(pi);
                }
            }
            IsLoadingData = false;
        }