示例#1
0
        private async Task RefreshMatchData(string action, string message)
        {
            try
            {
                string[] textArray = message.Split(';');
                string   matchID   = textArray[0];
                Match    match     = await _viewModel.GetMatchByIDAsync(matchID);

                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();
                    }
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        PopulatePageView(_viewModel.SelectedLiveMatch.MatchID == match?.MatchID);
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }