December 2019
Intermediate to advanced
598 pages
12h 21m
English
The final action method we are going to implement is a method for posting an answer to a question:
[HttpPost("answer")]public ActionResult<AnswerGetResponse> PostAnswer(AnswerPostRequest answerPostRequest){ var questionExists = _dataRepository.QuestionExists(answerPostRequest.QuestionId); if (!questionExists) { return NotFound(); } var savedAnswer = _dataRepository.PostAnswer(answerPostRequest); return savedAnswer;}
The method checks whether the question exists and returns a 404 HTTP status code if it doesn't. The answer is then passed to the data repository to insert into the database. The saved answer is returned from ...
Read now
Unlock full access