Untitled

mail@pastecode.io avatar
unknown
csharp
2 years ago
2.3 kB
1
Indexable
Never
 private async void RoundClick(object sender)
        {
            //string team = App.TeamsView.pickerTeam.SelectedItem as string;
            Console.WriteLine($"------------------->   Click");
            var btn = (Button) sender;

            int ogValue = Convert.ToInt32(btn.Text);

            Console.WriteLine($"------------------->   Click {ogValue}");
            string team = App.TVM.SelectedTeam;
                if (team == null || String.IsNullOrEmpty(team))
            {
                Console.WriteLine($"There was an error with selected team: {team}");
                await App.Current.MainPage.DisplayAlert("GC", "Please select a team first.", "Ok");
                return;
            }

            Console.WriteLine($"[ROUND CLICK] ------------------->   Click, team: {team}");

            string result = await App.Current.MainPage.DisplayPromptAsync($"{btn.ClassId} Score Input",
                    $"Please input {btn.ClassId} score:", placeholder: "0", keyboard: Keyboard.Numeric);
                if (!string.IsNullOrEmpty(result))
            {
                if (string.IsNullOrEmpty(result)) return;

                if (!double.TryParse(result, out double value))
                {
                    ((Entry) sender).Text = ogValue.ToString();
                }
                else
                {
                    btn.Text = result;
                    Console.WriteLine($"[ROUND CLICK] User input: {result} -> Sender: {btn.ClassId}");
                    //UpdateTeamLocally(team);
                    string updated = GetTeamInfo(team);
                    App.YVM.BeenEdited = true;
                    Console.WriteLine($"[TEAM UPDATE] Response: {updated}");
                    if (updated == "ERR")
                    {
                        await Task.Run(() =>
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                App.Current.MainPage.DisplayAlert("Game Center",
                                    "There was an error saving the team, Please try again.", "Ok");
                            });
                        });
                        return;
                    }
                }
            }
        }