Esempio 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));
        }
Esempio 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();
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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)));
        }
Esempio n. 6
0
 public async Task <Result <AnswerResponse> > Put([FromBody] UpdateAnswerCommand command) => await _service.Update(command);
Esempio n. 7
0
        public async Task <IActionResult> Update(UpdateAnswerCommand command)
        {
            var result = await Mediator.Send(command);

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

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