public UpdateAndNewMatchPage(MatchesViewModel viewModel, TypePages typePreviousPage) { _viewModel = viewModel; _typeOfPage = typePreviousPage; _viewModel.SetMatchAdditionalDetails(); InitializeComponent(); BindingContext = _viewModel.SelectedLiveMatch; SetPageButtonsAndTitle(typePreviousPage); CreateMatchActionButtons(); }
private void RefreshMatchData(string action, MatchDetails matchDetails) { try { Match match = matchDetails?.Match; if (match != null) { Match findMatch = _viewModel.AllMatches?.FirstOrDefault(x => x.MatchID == match.MatchID); if (findMatch != null) { int findMatchIndex = _viewModel.AllMatches.IndexOf(findMatch); _viewModel.AllMatches?.Insert(findMatchIndex, match); _viewModel.AllMatches?.Remove(findMatch); } else { _viewModel.AllMatches?.Add(match); } //if (match.StatusID != findMatch?.StatusID) //{ // await _viewModel.GetStandingsAsync(); //} bool isSelectedMatch = _viewModel.SelectedLiveMatch.MatchID == match.MatchID; if (isSelectedMatch) { Match selectedMatch = matchDetails.Match; selectedMatch.PlayersOfMatch = new ObservableCollection <PlayerOfMatch>(matchDetails.PlayersOfMatch); selectedMatch.EventsOfMatch = new ObservableCollection <EventOfMatch>(matchDetails.EventsOfMatch); _viewModel.SelectedLiveMatch = selectedMatch; _viewModel.SelectedLiveMatch.LiveTime = selectedMatch.LiveTime; _viewModel.TimeCounter.MatchesTime(_viewModel, new ObservableCollection <Match>()); _viewModel.SetMatchAdditionalDetails(); _viewModel.SelectedLiveMatch.IsLoadingSelectedMatch = false; } Device.BeginInvokeOnMainThread(() => { PopulatePageView(false); }); } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }