private CommandResponse ExecuteEditQuestion(EditQuestionCommand command)
        {
            var existingQuestion = Questions.FirstOrDefault(q => q.Id == command.QuestionId);

            if (existingQuestion == null)
            {
                return(CommandResponse.Failure($"Question {command.QuestionId} doesn't exist."));
            }

            existingQuestion.History.Add(new PostHistoryItem
            {
                Author = existingQuestion.Author,
                Text   = existingQuestion.Text
            });

            existingQuestion.Title = command.Title;
            existingQuestion.Text  = command.Text;
            return(CommandResponse.Success(existingQuestion));
        }
Beispiel #2
0
        public async Task <ActionResult> Update([FromRoute] Guid challengeId, Guid id, EditQuestionCommand command)
        {
            if (id != command.Id || challengeId != command.ChallengeId)
            {
                return(BadRequest());
            }

            return(Ok(await Mediator.Send(command)));
        }
Beispiel #3
0
 public async Task <Guid> EditQuestionAsync([FromBody] EditQuestionCommand request)
 => await _mediator.Send(request);