Class QuestionViewModel

    • Constructor Detail

      • QuestionViewModel

        public QuestionViewModel​(@NonNull
                                 Application application)
        Class constructor. Instantiates local class variables. Additionally, gets all the questions from the server.
        Parameters:
        application - an application.
    • Method Detail

      • refreshQuestions

        public void refreshQuestions()
        gets a list of all questions from the question repository. Additionally, subscribes to the result and puts the result in the local variable questions.
      • updateQuestion

        public void updateQuestion​(Question question)
        updates a question and sends a question to the questionRepository for updating on the server. Additionally, subscribes to the result and puts the result in the local variable question. Then reinitializes the questions field so that it will refresh on the screen.
        Parameters:
        question - An updated Question object.
      • createQuestion

        public void createQuestion​(Question question)
        creates a question and sends a question to the questionRepository for creation on the server. Additionally, subscribes to the result and puts the result in the local variable question. Then reinitializes the questions field so that it will refresh on the screen.
        Parameters:
        question - A new Question object.
      • refreshQuestion

        public void refreshQuestion​(UUID questionId)
        gets a question from the questionRepository which subsequently gets a question from the server. Additionally, subscribes to the result and puts the result in the local variable question. Then reinitializes the questions field so that it will refresh on the screen.
        Parameters:
        questionId - A questionId in the form of a universally unique identifier.
      • deleteQuestion

        public void deleteQuestion​(UUID questionId)
        deletes a question from the questionRepository which subsequently deletes a question from the server.
        Parameters:
        questionId - A questionId in the form of a universally unique identifier.