Exemplo n.º 1
0
        private void SendResult()                  // send all relevant statistics to database
        {
            LocalDataStorage.RefreshSaveFileXML(); // insure we have last progress in local storage
            Guid gamerGuid = LocalDataStorage.GetGamerGuid();

            if (gamerGuid == Guid.Empty) // completely new gamer
            {
                gamerGuid = Guid.NewGuid();
                ResultDO.SendGamerToDatabase(gamerGuid, GamerNameTextBox.Text); // send new gamer to database
            }
            else if (!ResultDO.IsGuidInDatabase(gamerGuid))                     // wrong Guid of gamer, which isn't in database
            {
                gamerGuid = Guid.NewGuid();
                ResultDO.SendGamerToDatabase(gamerGuid, GamerNameTextBox.Text); // send new gamer to database
            }

            ResultDO.SendResultToDatabaseAsync(
                gamerGuid,
                LocalDataStorage.GetLastCurrentScore(),
                GameBoard.GetBiggestTile()
                );
            this.Visibility = Visibility.Collapsed;
            LocalDataStorage.SetGamerGuid(gamerGuid); // insure, that program will recognize gamer next time

            LocalDataStorage.ClearSaveFileBeforeNewGame();
        }