public LeagueDetailsPage(League league)
        {
            league.RefreshChallenges();
            league.RefreshMemberships();
            ViewModel.LeagueId = league.Id;

            SetTheme(league);
            Initialize();
        }
Beispiel #2
0
        void CacheLeague(League l)
        {
            {
                var toRemove = DataManager.Instance.Memberships.Values.Where(m => m.LeagueId == l.Id && !l.Memberships.Select(mm => mm.Id).Contains(m.Id));

                foreach (var m in toRemove)
                {
                    Membership mem;
                    DataManager.Instance.Memberships.TryRemove(m.Id, out mem);
                }

                foreach (var m in l.Memberships)
                {
                    l.MembershipIds.Add(m.Id);
                    DataManager.Instance.Memberships.AddOrUpdate(m);                     //need to update too
                    m.Athlete?.LocalRefresh();
                }
            }

            {
                var toRemove = DataManager.Instance.Challenges.Values.Where(c => c.LeagueId == l.Id && !l.OngoingChallenges.Select(cc => cc.Id).Contains(c.Id));

                foreach (var c in toRemove)
                {
                    Challenge ch;
                    DataManager.Instance.Challenges.TryRemove(c.Id, out ch);
                }

                foreach (var c in l.OngoingChallenges)
                {
                    DataManager.Instance.Challenges.AddOrUpdate(c);
                }
            }

            DataManager.Instance.Leagues.AddOrUpdate(l);
            l.RefreshChallenges();
            l.RefreshMemberships();
        }