/// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)  //e is the unique ID
        {
            App.IsInternetAvailable();

            int id = await AdData.GetAdId();
            int count = MemoryManager.AppMemoryUsageLimit / (1024 * 1024) > 700 ? 55 : 40;
            HelperMethods.CreateSingleAdUnit(id, "HorizontalAdSmall", AdGrid);
            HelperMethods.CreateAdUnits(id, "HorizontalAdSmall", AdGrid2, count);

            reviewApp();

            // Set up champion data 
            champions = await StatsDataSource.GetChampionsAsync();
            if (champions == null) {
                MessageDialog messageBox = new MessageDialog("Make sure your internet connection is working and try again!");
                await messageBox.ShowAsync();
                Application.Current.Exit();
            }

            var GroupedChampions = champions.ChampionInfos.ToAlphaGroups(x => x.Value.Name); 
            DefaultViewModel["GroupedChampions"] = GroupedChampions;

            // Set up roles
            string selectedRole = (string)e.NavigationParameter;
            DefaultViewModel["Roles"] = StatsDataSource.GetRoles(); 
            DefaultViewModel["SelectedRole"] = selectedRole;


            // Configure view to either 'All' or filtered role
            if (selectedRole != "All")
            {
                // Do a null check incase of race condition with UI, and raise a flag incase UI hasn't loaded yet for its load to set visibility
                isInitialAllView = false;
                if (JumpList != null)
                {
                    JumpList.Visibility = Visibility.Collapsed;
                }

                DefaultViewModel["Filter"] = champions.ChampionInfos.Where(x => x.Value.Tags[0] == selectedRole).OrderBy(x => x.Value.Name);

                if (FilterGridView != null)
                {
                    FilterGridView.Visibility = Visibility.Visible;
                }
            }
        }
        public async static Task<Champions> GetChampionsAsync()
        {
            if (Champions != null && Champions.ChampionInfos != null)
                return Champions;

            Champions = new Champions();
            try
            {
                Uri dataUri = new Uri("ms-appx:///DataModel/Champions.json");
                StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
                string jsonText = await FileIO.ReadTextAsync(file);
                JObject champsJson = JObject.Parse(jsonText);
                Champions = JsonConvert.DeserializeObject<Champions>(champsJson.ToString());
                return Champions;
            }
            catch (HttpRequestException hre)
            {
                ErrorMessage = hre.Message;
                return null;
            }
            catch (JsonException e)
            {
                ErrorMessage = e.Message;
                return null;
            }

            catch (Exception e)
            {
                ErrorMessage = e.Message;
                return null;
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>.
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.IsInternetAvailable();

            int id = await AdData.GetAdId();
            int count = MemoryManager.AppMemoryUsageLimit / (1024 * 1024) > 700 ? 55 : 40;
            HelperMethods.CreateSingleAdUnit(id, "HorizontalAdSmall", AdGrid);
            HelperMethods.CreateAdUnits(id, "HorizontalAdSmall", AdGrid2, count);

            // Setup the underlying UI 
            string champKey = (string)e.NavigationParameter;
            champions = await StatsDataSource.GetChampionsAsync();
       
            // Could be passed either the key or name, check for either case
            champInfo = champions.ChampionInfos.Where(x => x.Key == champKey).FirstOrDefault().Value;
            if (champInfo == null)
                champInfo = champions.ChampionInfos.Values.Where(x => x.Name == champKey).FirstOrDefault();

            this.DefaultViewModel["Champion"] = champInfo;
            this.DefaultViewModel["Filter"] = champions.ChampionInfos.OrderBy(x => x.Value.Name);


            // If navigating via a counterpick, on loading that page, remove the previous history so the back page will go to main or role, not champion
            var prevPage = Frame.BackStack.ElementAt(Frame.BackStackDepth - 1);
            if (prevPage.SourcePageType.Equals(typeof(ChampionPage)))
            {
                Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
            }

            // Grab the champion feedback from the server 
            await commentViewModel.GetChampionFeedbackAsync(champInfo.Name);

            // Check if an there was no champion retrieved as well as an error message (must be internet connection problem)
            if (commentViewModel.ChampionFeedback == null){
                MessageDialog messageBox = new MessageDialog("Make sure your internet connection is working and try again!");
                await messageBox.ShowAsync();
                Application.Current.Exit();
            }
           
            // Collapse the progress ring once counters have been loaded assuming the textboxes load first
            DefaultViewModel["LoadingVisibility"] = Visibility.Collapsed;

            // Make updates to champion comments observable
            this.DefaultViewModel["ChampionFeedback"] = commentViewModel.ChampionFeedback;
        }