public ActionResult <QuestionGetSingleResponse> GetQuestion(int questionId)
        {
            var question = _cache.Get(questionId);

            if (question == null)
            {
                question = _dataRepository.GetQuestion(questionId);
                if (question == null)
                {
                    return(NotFound());
                }
                _cache.Set(question);
            }
            return(question);
        }
Exemplo n.º 2
0
        GetQuestion(int questionId)
        {
            // TODO - call the data repository to get the question
            var question = _cache.Get(questionId);

            // TODO - return HTTP status code 404 if the question isn't found
            if (question == null)
            {
                question = _dataRepository.GetQuestion(questionId);
                if (question == null)
                {
                    return(NotFound());
                }
                _cache.Set(question);
            }
            // TODO - return question in response with status code 200
            return(question);
        }
Exemplo n.º 3
0
        public async Task <ActionResult <QuestionGetSingleResponse> > GetQuestion(int questionId)
        {
            var question = _cache.Get(questionId);

            if (question != null)
            {
                return(question);
            }

            question = await _dataRepository.GetQuestion(questionId);

            if (question == null)
            {
                return(NotFound());
            }

            _cache.Set(question);
            return(question);
        }
Exemplo n.º 4
0
        public async Task <ActionResult <QuestionGetSingleResponse> > GetQuestion(int questionId)
        {
            // FIRST IF QUESTION : CACHE
            var question = _cache.Get(questionId);

            if (question == null)
            {
                // SECOND IF QUESTION : RETRIEVE DATA
                // TODO - call the data repository to get the question
                question = await _dataRepository.GetQuestion(questionId);

                // TODO - return HTTP status code 404 if the question isn't found
                if (question == null)
                {
                    return(NotFound());
                }
                _cache.Set(question);
            }

            // TODO - return question in response with status code 200
            return(question);
        }