public async Task Executar(CadastrarLivroEntrada entrada) { if (entrada is null) { this._CadastrarLivroSaidaPort.WriteError("Entrada não pode ser nula"); return; } ICadastroLivro CadastroLivro = await this._CadastroLivroRepository.GetCadastroLivro().ConfigureAwait(false); if (CadastroLivro is null) { this._CadastrarLivroSaidaPort.WriteError("Cadastro de livros não existe."); return; } ILivro livro = await this._CadastroLivroService.CadastrarLivro(CadastroLivro, new Livro() { autor = entrada.autor, isbn = entrada.isbn, nome = entrada.nome, preco = entrada.preco }); await this._unitOfWork.Save().ConfigureAwait(false); this.BuildOutput(livro.isbn.id); }
public object CadastrarLivro([FromBody] CadastrarLivroRequest request) { var result = new CadastrarLivroEntrada(request.isbn, request.nome, request.preco, request.autor); /* mediator não funciona na minha versão de VSS2017 pq precisa de .net core acima de 2.1 */ /* * await mediator.PublishAsync(result) * .ConfigureAwait(false); */ return(result); }
public async Task <IActionResult> Cadastrar( [FromServices] CadastrarLivroPresenter presenter, [FromForm] CadastrarLivroRequest request) { var inputmediator = new CadastrarLivroEntrada(request.isbn, request.nome, request.preco, request.autor); /* mediator não funciona na minha versão de VSS2017 pq precisa de .net core acima de 2.1 */ /* * await mediator.PublishAsync(inputmediator) * .ConfigureAwait(false); */ return(presenter.ViewModel); }