Exemplo n.º 1
0
        public IActionResult CreateQuestions([FromBody] IEnumerable <QuestionCreateDto> questions)
        {
            if (questions == null || !questions.Any())
            {
                return(BadRequest());
            }

            var questionEnties = Mapper.Map <IEnumerable <Questions> >(questions);

            _questionRepository.AddManyQuestion(questionEnties);
            if (!_questionRepository.Save())
            {
                return(StatusCode(500, "Đăng ký câu hỏi không thành công !"));
            }
            //return Ok();

            var questionCollectionToReturn = Mapper.Map <IEnumerable <QuestionDto> >(questionEnties);
            var idAsString = string.Join(",", questionEnties.Select(x => x.Id));

            return(CreatedAtRoute("GetQuestionCollection", new { ids = idAsString }, questionCollectionToReturn));
        }