public async Task <Unit> Handle(DeleteContaCommand request, CancellationToken cancellationToken) { var conta = mapper.Map <Conta>(request); contaDomainService.Delete(conta); await mediator.Publish(new ContaNotification { Conta = conta, Action = ActionNotification.Excluir }); return(Unit.Value); }
public async Task <IActionResult> Delete(int id) { try { DeleteContaCommand command = new DeleteContaCommand { Id = id }; await contaApplicationService.Delete(command); return(Ok(new { message = "Conta excluída com sucesso!" })); } catch (ValidationException e) { return(BadRequest(ValidationAdapter.Parse(e.Errors))); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public async Task Delete(DeleteContaCommand command) { await mediator.Send(command); }