private async void GetTeamDataAsync(ChampionshipType championshipType) { switch (championshipType) { case ChampionshipType.Male: RepresentationRepo = new MaleRepresentation(); break; case ChampionshipType.Female: RepresentationRepo = new FemaleRepresentation(); break; } Cursor = Cursors.WaitCursor; RepresentationsData = (List <Representation>) await RepresentationRepo.GetAllTeams(); Cursor = Cursors.Default; if (RepresentationsData == null) { MessageBox.Show("Unable to fetch player data"); } else { RepresentationsData.Sort(); FillRepresentationCombobox(); } }
private async void LoadCbRepresentations() { switch (ChampionshipType) { case ChampionshipType.Male: RepresentationRepo = new MaleRepresentation(); break; case ChampionshipType.Female: RepresentationRepo = new FemaleRepresentation(); break; } Cursor = Cursors.Wait; Representations = (List <Representation>) await RepresentationRepo.GetAllTeams(); Cursor = Cursors.Arrow; if (Representations != null) { Representations.Sort(); foreach (var representation in Representations) { cbRepresentations.Items.Add(representation); } if (File.Exists(Properties.Settings.Default.Representation_Filepath)) { var jsonRepresentation = File.ReadAllText(Properties.Settings.Default.Representation_Filepath); if (!string.IsNullOrEmpty(jsonRepresentation)) { RepresentationSaveFile saveFile = JsonConvert.DeserializeObject <RepresentationSaveFile>(jsonRepresentation); if (saveFile.ChampionshipType == this.ChampionshipType) { FavoriteRepresentation = saveFile.Representation; cbRepresentations.SelectedItem = FavoriteRepresentation; } } } } else { MessageBox.Show("Unable to fetch representation data!"); } }