protected override Result Handle(AddNewQuestionCommand request)
        {
            EnsureArg.IsNotNull(request);

            var question = Domain.Question.Create(request.QuestionModel.Name);

            questionsRepository.Add(question);
            questionsRepository.SaveChanges();

            return(Result.Ok());
        }
예제 #2
0
        public IActionResult Post([FromBody] QuestionViewModel questionsViewModel)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(Response(questionsViewModel));
            }
            var questionEvent = _mapper.Map <Question>(questionsViewModel);

            _questionsRepository.Add(questionEvent);
            _questionsRepository.SaveChanges();

            return(Response(questionsViewModel));
        }
예제 #3
0
        public async Task <int> Create(Question question)
        {
            if (question is null)
            {
                throw new ArgumentNullException(nameof(question));
            }

            var isInvalid = string.IsNullOrWhiteSpace(question.MemberId.ToString()) ||
                            string.IsNullOrWhiteSpace(question.Description) ||
                            question.MemberId == default;

            if (isInvalid)
            {
                throw new QuestionException(QUESTION_IS_INVALID);
            }

            var questionId = await _questionsRepository.Add(question);

            return(questionId);
        }
예제 #4
0
 public Question Post([FromBody] NewQuestionRequest question) => _questionsRepository.Add(question.ToEntity());
예제 #5
0
 public void Add(Questions entity)
 {
     _questions.Add(entity);
 }