Exemplo n.º 1
0
        private async void PostToServer_Click(object sender, EventArgs e)
        {
            if (Queue.Count <= 0)
            {
                toolTip.ToolTipTitle = "Nothing to POST";
                toolTip.Show("Add items to the Queue before POSting to the API.", postToServer, 0, -20, 2500);
                return; // nothing to POST, dont run the method.
            }

            using var lockout = new ToolLockout(this);
            await PostQueueToLive();
        }
Exemplo n.º 2
0
        private async void PostWinner_Click(object sender, EventArgs e)
        {
            if (currentGame.SelectedItem is null)
            {
                toolTip.ToolTipTitle = "No Guess Selected on Live";
                toolTip.Show("Select a guess from the Live panel to POST it as the winning guess.", postWinner, 0, -20, 2500);
                return; // nothing to POST, dont run the method.
            }

            var res = MessageBox.Show("Are you sure this guess is the winning guess? Submiting this will prevent editing of this game through the API.",
                                      "POST Winner", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (res == DialogResult.Yes)
            {
                using var lockout = new ToolLockout(this);

                await PostWinnerToLive((CardGuess)currentGame.SelectedItem);
            }
        }
Exemplo n.º 3
0
 private async void GetCurrentGame_Click(object sender, EventArgs e)
 {
     using var lockout = new ToolLockout(this);
     await GetCurrentGame();
 }
Exemplo n.º 4
0
        public async Task SaveGuess(CardGuess?guess = null)
        {
            // Make sure all inputs are filled
            if (!await VerifyAllInputsAreFilled())
            {
                return;
            }
            if (CurrentGameId is null)
            {
                return;
            }

            if (winnerCheckBox.Checked)
            {
                // Make sure this is the winning card.
                var res = MessageBox.Show("Are you sure this is the Winning Guess?\n" +
                                          "Marking this guess as the winner will close this game, sync queue data to the server, and make the data un-editibale from the API.\n\n" +
                                          "Press No to store guess in Queue as a noral guess.\n" +
                                          "Press Cancel to remove this guess.\n" +
                                          "Press Yes to continue.\n\n" +
                                          "Guess:\n" +
                                          $"{cardSelector.Text} - {userIdInput.Text} [{dateInput.Text} - {timeInput.Text}]"
                                          , "Confirm Winner", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

                if (res == DialogResult.No)
                {
                    winnerCheckBox.Checked = false;
                }
                else if (res == DialogResult.No)
                {
                    return;
                }
            }

            // Build the CardGuess object
            if (guess is null)
            {
                guess = new CardGuess();
                Queue.Add(guess);
            }

            // Save values to the guess object.
            guess.Team   = teamSelector.Text;
            guess.Card   = cardSelector.Text;
            guess.Date   = dateInput.Text;
            guess.Time   = timeInput.Text;
            guess.UserId = userIdInput.Text;
            guess.GameId = CurrentGameId ?? -1;

            // And update the queue box.
            await UpdateQueueBox();

            // This time we are sure this is correct, so lets execute the code.
            if (winnerCheckBox.Checked)
            {
                using var lockout = new ToolLockout(this);
                // POST updates
                await PostQueueToLive();

                // POST winner
                await PostWinnerToLive(guess);

                // Then clear the queue data
                var q = ClearQueue();
                // GET the new current game
                await GetCurrentGame();

                await q;
            }

            await ClearEditFields();
        }