/// <summary>Refreshes a filtered list based on selectedIndex.</summary> /// <param name="filterText">The filter text.</param> /// <param name="selectedIndex">Index of the selected.</param> internal void RefreshList(string filterText, int selectedIndex) { if (filterText == null) { filterText = ""; } switch (selectedIndex) { case 0: FilteredAudience.Clear(); foreach (var filtered in AudienceChallenges) { if (filtered.Game != null && filtered.Game.Name.ToLower().StartsWith(filterText)) { FilteredAudience.Add(filtered); } else if (filterText.Equals("")) { FilteredAudience.Add(filtered); } } break; case 1: FilteredCrew.Clear(); foreach (var filtered in CrewChallenges) { if (filtered.Game != null && filtered.Game.Name.ToLower().StartsWith(filterText)) { FilteredCrew.Add(filtered); } else if (filterText.Equals("")) { FilteredCrew.Add(filtered); } } break; case 2: FilteredMulti.Clear(); foreach (var filtered in MultipleChoiceChallenges.Where(x => x.ChallengeTask.ToLower().StartsWith(filterText))) { FilteredMulti.Add(filtered); } break; case 3: FilteredMusic.Clear(); foreach (var filtered in MusicChallenges) { if (filtered.Song != null && filtered.Song.Name.ToLower().StartsWith(filterText)) { FilteredMusic.Add(filtered); } else if (filterText.Equals("")) { FilteredMusic.Add(filtered); } } break; case 4: FilteredQuiz.Clear(); foreach (var filtered in QuizChallenges.Where(x => x.ChallengeTask.ToLower().StartsWith(filterText))) { FilteredQuiz.Add(filtered); } break; case 5: FilteredScreen.Clear(); foreach (var filtered in ScreenshotChallenges) { if (filtered.Image != null && filtered.Image.Name.ToLower().StartsWith(filterText)) { FilteredScreen.Add(filtered); } else if (filterText.Equals("")) { FilteredScreen.Add(filtered); } } break; case 6: FilteredSilhu.Clear(); foreach (var filtered in SilhouetteChallenges) { if (filtered.Image != null && filtered.Image.Name.ToLower().StartsWith(filterText)) { FilteredSilhu.Add(filtered); } else if (filterText.Equals("")) { FilteredSilhu.Add(filtered); } } break; case 7: FilteredSolo.Clear(); foreach (var filtered in SologameChallenges) { if (filtered.Game != null && filtered.Game.Name.ToLower().StartsWith(filterText)) { FilteredSolo.Add(filtered); } else if (filterText.Equals("")) { FilteredSolo.Add(filtered); } } break; } }
/// <summary>Initializes a new instance of the <see cref="CreateChallengesViewModel"/> class.</summary> public CreateChallengesViewModel() { EditCommand = new RelayCommand <ChallengeBase>(async param => { switch (param.GetDiscriminator()) { case "AudienceChallenge": case "CrewChallenge": case "SologameChallenge": ObjectsViewModel.EditCommand.Execute((param as GameChallenge).Game); break; case "MultipleChoiceChallenge": case "QuizChallenge": await AnswersDataAccess.EditAnswersAsync((param as QuestionChallenge).Answers); break; case "MusicChallenge": ObjectsViewModel.EditCommand.Execute((param as MusicChallenge).Song); break; case "ScreenshotChallenge": case "SilhouetteChallenge": ObjectsViewModel.EditCommand.Execute((param as ImageChallenge).Image); break; } await ChallengesDataAccess.EditChallengeAsync(param); }, param => param != null); DeleteCommand = new RelayCommand <ChallengeBase>(async param => { if (await ChallengesDataAccess.DeleteChallengeAsync(param)) { switch (param.GetDiscriminator()) { case "AudienceChallenge": AudienceChallenges.Remove(param as AudienceChallenge); FilteredAudience.Remove(param as AudienceChallenge); break; case "CrewChallenge": CrewChallenges.Remove(param as CrewChallenge); FilteredCrew.Remove(param as CrewChallenge); break; case "MultipleChoiceChallenge": MultipleChoiceChallenges.Remove(param as MultipleChoiceChallenge); FilteredMulti.Remove(param as MultipleChoiceChallenge); break; case "MusicChallenge": MusicChallenges.Remove(param as MusicChallenge); FilteredMusic.Remove(param as MusicChallenge); break; case "QuizChallenge": QuizChallenges.Remove(param as QuizChallenge); FilteredQuiz.Remove(param as QuizChallenge); break; case "ScreenshotChallenge": ScreenshotChallenges.Remove(param as ScreenshotChallenge); FilteredScreen.Remove(param as ScreenshotChallenge); break; case "SilhouetteChallenge": SilhouetteChallenges.Remove(param as SilhouetteChallenge); FilteredSilhu.Remove(param as SilhouetteChallenge); break; case "SologameChallenge": SologameChallenges.Remove(param as SologameChallenge); FilteredSolo.Remove(param as SologameChallenge); break; } } }, param => param != null); }