...
/Creating an Action Method for Getting a Single Question
Creating an Action Method for Getting a Single Question
Learn to create an action method for getting a single question.
We'll cover the following...
Implementing action method for getting a single question
Let’s move on to implementing the action method for getting a single question. To do that, follow these steps:
Add the following skeleton method underneath the
GetUnansweredQuestions
method:
Press + to interact
[HttpGet("{questionId}")]public ActionResult<QuestionGetSingleResponse>GetQuestion(int questionId){// TODO - call the data repository to get the// question// TODO - return HTTP status code 404 if the// question isn't found// TODO - return question in response with status// code 200}
Note the HttpGet
attribute parameter.
Note: The curly brackets tell ASP.NET to put the endpoint subpath in a variable that can be referenced as a method parameter.
In this method, the ...