コード例 #1
0
ファイル: Home.cs プロジェクト: wuchangqi/ifixit-microsoft
        private void BindFavorites(RESTModels.Favorites.RootObject[] r)
        {
            FavoritesItems.Clear();
            HasFavorites = false;

            if (r != null && r.Any())
            {
                FavoritesDescription = string.Empty;
                HasFavorites         = true;
                foreach (var item in r.Where(item => FavoritesItems.All(o => o.UniqueId != item.guide.guideid.ToString())))
                {
                    FavoritesItems.Add(new Models.UI.HomeItem
                    {
                        Name = item.guide.title
                        ,
                        UniqueId = item.guide.guideid.ToString()
                        ,
                        ImageUrl = item.guide.image != null ? item.guide.image.standard : ""
                        ,
                        BigImageUrl = item.guide.image != null ? item.guide.image.large : ""
                        ,
                        IndexOf = 1
                    });
                }
            }
            else
            {
                FavoritesDescription = International.Translation.NoFavorites;
            }
        }
コード例 #2
0
ファイル: Home.cs プロジェクト: wuchangqi/ifixit-microsoft
        private async Task GetUserFavorites()
        {
            LoadingCounter++;
            if (AppBase.Current.User != null)
            {
                IsLoggedIn = true;
                if (_settingsService.IsConnectedToInternet())
                {
                    var r = await Broker.GetFavorites(AppBase.Current.User);

                    await _storageService.WriteData(Constants.FAVORITES, r.SaveAsJson());

                    BindFavorites(r);
                }
                else
                {
                    await LoadLocalFavories();
                }
            }
            else
            {
                IsLoggedIn           = false;
                FavoritesDescription = International.Translation.LoginToViewYourFavorites;
                FavoritesItems.Clear();
            }
            LoadingCounter--;
        }