コード例 #1
0
        public async Task <IActionResult> CreateOrUpdateAnswerAsync([FromBody] AnswerResource body)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var answer = _mapper.Map <AnswerResource, Answer>(body);

            var response = await _answerService.CreateOrUpdateAnswerAsync(answer);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }

            var answerResource = _mapper.Map <Answer, AnswerResource>(response.Answer);

            return(Ok(answerResource));
        }