Exemplo n.º 1
0
        /// <summary>
        /// Sets the current challenge, if there already is one then throws AlreadyInAChallengeException.
        /// </summary>
        /// <param name="newChallenge">Which challenge to undertake for the user.</param>
        public void SetCurrentChallenge(Challenge challenge)
        {
            // can not start a new challenge before completing the old one

            if (connectToDatabase.onGoingChallenge(Username))
            {
                CurrentChallenge = new CurrentChallenge(challenge);
            }

            // new challenge is set for the user
            else
            {
                if (connectToDatabase.setCurrentChallenge(Username, challenge.Name))
                {
                    Debug.WriteLine("connectToDatabase.setCurrentChallenge(Username,challenge.Name); has run.");
                    CurrentChallenge = new CurrentChallenge(challenge);
                }
            }
        }