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); }
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); }
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); }
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); }