public async Task <IActionResult> Post([FromBody] ApplicationCore.Models.Question question) { if (!ModelState.IsValid) { return(BadRequest()); } if (question.QuestionChoices.Count < 4) { return(BadRequest("Question must have at least 4 choices.")); } if (!await _questionRepo.CategoryExistsAsync((int)question.CategoryId)) { return(BadRequest($"Category with id {question.CategoryId} does not exist.")); } var createdItem = await _questionRepo.AddQuestionAsync(question); return(CreatedAtAction( actionName: nameof(Get), routeValues: new { id = createdItem.QuestionId }, value: createdItem)); }