Exemplo n.º 1
0
        public async Task <IActionResult> Put(UpdateFormaPagamentoCommand command)
        {
            try
            {
                await formaPagamentoApplicationService.Update(command);

                return(Ok(new { message = "Forma de Pagamento atualizada com sucesso!" }));
            }
            catch (ValidationException e)
            {
                return(BadRequest(ValidationAdapter.Parse(e.Errors)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
        public async Task <Unit> Handle(UpdateFormaPagamentoCommand request, CancellationToken cancellationToken)
        {
            var formaPagamento = mapper.Map <FormaPagamento>(request);

            var validate = new FormaPagamentoValidation().Validate(formaPagamento);

            if (!validate.IsValid)
            {
                throw new ValidationException(validate.Errors);
            }

            formaPagamentoDomainService.Update(formaPagamento);

            await mediator.Publish(new FormaPagamentoNotification
            {
                Action         = ActionNotification.Atualizar,
                FormaPagamento = formaPagamento
            });

            return(Unit.Value);
        }
Exemplo n.º 3
0
 public Task Update(UpdateFormaPagamentoCommand command)
 {
     return(mediator.Send(command));
 }