Example #1
0
        public ActionResult <int> PostAnswer(AnswerInputModel answerModel)
        {
            Mapper           mapper    = new Mapper();
            AnswerDTO        answerDto = mapper.ConvertAnswerInputModelToAnswerDTO(answerModel);
            AuthorDataAccess answer    = new AuthorDataAccess();
            var question = answer.GetQuestionById(answerModel.QuestionID);

            if (question == null)
            {
                return(BadRequest("Вопроса не существует"));
            }
            if (string.IsNullOrWhiteSpace(answerModel.Value))
            {
                return(BadRequest("Введите ответ"));
            }
            if (answerModel.Correct == null)
            {
                return(BadRequest("Введите корректный ответ или нет"));
            }
            return(Ok(answer.AddAnswer(answerDto)));
        }