Action methods are where we can write code to handle requests to a resource. In this section, we are going to implement action methods that will handle requests to the questions resource. We will cover the GET, POST, PUT, and DELETE HTTP methods.
Creating controller action methods
Creating an action method for getting questions
Let's implement our first action method, which is going to return an array of all the questions:
- Let's create a method called GetQuestions in our API controller class:
[HttpGet]
public IEnumerable<QuestionGetManyResponse> GetQuestions()
{
// TODO - get questions from data repository
// TODO - return questions in the response
}
We decorate the method with the HttpGet attribute to...