public async Task <ActionResult <Question> > Get(int id) { if (await QuestionRepo.GetQuestionById(id) is Question question) { return(question); } return(NotFound()); }
public async Task <IActionResult> Post([FromBody] Question question) { try { var id = await QuestionRepo.CreateQuestion(question); Question model = await QuestionRepo.GetQuestionById(id); return(CreatedAtRoute("Get", new { Id = id }, model)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } }