示例#1
0
        private void NotifyCanExecuteCommands()
        {
            if (EditAnswerCommand == null || DeleteAnswerCommand == null)
            {
                return;
            }

            EditAnswerCommand.NotifyCanExecuteChanged();
            DeleteAnswerCommand.NotifyCanExecuteChanged();
        }
        private CommandResponse ExecuteEditAnswer(EditAnswerCommand command)
        {
            var existingAnswer = Questions.SelectMany(q => q.Answers).SingleOrDefault(a => a.Id == command.AnswerId);

            if (existingAnswer == null)
            {
                return(CommandResponse.Failure($"Answer {command.AnswerId} doesn't exist."));
            }

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

            existingAnswer.Text = command.Text;
            return(CommandResponse.Success(existingAnswer));
        }
 public async Task <ActionResult <TicketItemViewModel> > PatchItem([FromBody] EditAnswerCommand cmd) =>
 Ok(await _mediator.Send(cmd));