Exemplo n.º 1
0
        public async Task <IActionResult> UpdateServiceAnswer(int answerId, [FromBody] ServiceAnswerDetails request)
        {
            var updateServiceAnswerCommand = new UpdateAnswerCommand(answerId, request);

            var result = await mediator.Send(updateServiceAnswerCommand);

            return(StatusCode((int)result.Code, result.Value));
        }
Exemplo n.º 2
0
        public async Task Should_Update_Answer()
        {
            var command = new UpdateAnswerCommand()
            {
                Id   = _Answer.Id,
                Name = "TESTE"
            };

            var result = await _service.Update(command);

            result.Success.Should().BeTrue();
        }
Exemplo n.º 3
0
        public async Task Should_Not_Update_Answer()
        {
            var command = new UpdateAnswerCommand()
            {
                Id = _Answer.Id
            };

            var result = await _service.Update(command);

            result.Success.Should().BeFalse();
            result.Message.Should().Be(AnswerValidationMessages.NAME);
        }
Exemplo n.º 4
0
        public async Task <ValidationResult> Validate(UpdateAnswerCommand command)
        {
            var result = new ValidationResult();

            if (string.IsNullOrEmpty(command.Name))
            {
                result.AddMessage(AnswerValidationMessages.NAME);
            }
            else if (await _repository.VerifyExistence(command.Name, command.Id))
            {
                result.AddMessage(AnswerValidationMessages.NAME_EXISTS);
            }

            return(result);
        }
Exemplo n.º 5
0
        public async Task <Result <AnswerResponse> > Update(UpdateAnswerCommand command)
        {
            var validationResult = Validate(await _updateAnswerCommandValidator.Validate(command));

            if (!validationResult.Success)
            {
                return(validationResult);
            }

            var Answer = await _repository.Get(command.Id);

            Answer
            .SetName(command.Name);

            await _repository.Update(Answer);

            return(new Result <AnswerResponse>(AnswerResponse.ToResponse(Answer)));
        }
Exemplo n.º 6
0
 public async Task <Result <AnswerResponse> > Put([FromBody] UpdateAnswerCommand command) => await _service.Update(command);
Exemplo n.º 7
0
        public async Task <IActionResult> Update(UpdateAnswerCommand command)
        {
            var result = await Mediator.Send(command);

            return(GetResponse(result));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Update([FromBody] UpdateAnswerCommand command)
        {
            await _mediator.Send(command);

            return(NoContent());
        }
Exemplo n.º 9
0
 public async Task <IActionResult> UpdatePollAnswer(UpdateAnswerCommand request)
 {
     return(Ok(await _mediator.Send(request)));
 }