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()); }
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)); }
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); }
public Question Post([FromBody] NewQuestionRequest question) => _questionsRepository.Add(question.ToEntity());
public void Add(Questions entity) { _questions.Add(entity); }