Ejemplo n.º 1
0
        private void PromptAndAddNewQuestion()
        {
            API_Question question = this.consoleService.PromptForQuestion();

            if (this.questionService.CreateQuestion(question) != null)
            {
                Console.WriteLine("Question Created");
            }
        }
Ejemplo n.º 2
0
        private void DisplayRandomQuestion()
        {
            API_Question question = questionService.GetRandomQuestion();

            if (question != null)
            {
                Console.WriteLine(question);
            }
            else
            {
                Console.WriteLine("There were no questions available to display.");
            }
        }
        public API_Question CreateQuestion(API_Question question)
        {
            RestRequest request = new RestRequest(BASE_URL);

            request.AddJsonBody(question);

            var response = client.Post <API_Question>(request);

            if (response.IsSuccessful && response.ResponseStatus == ResponseStatus.Completed)
            {
                return(response.Data);
            }
            else
            {
                Console.WriteLine("An error occurred creating a new question");

                return(null);
            }
        }