public async Task <IActionResult> Delete(int id)
        {
            var dto = new PessoaDeleteCommand {
                Id = id
            };
            var result = await _mediator.Send(dto);

            return(Ok(result));
        }
示例#2
0
        public async Task <OperationResult <PessoaEntity> > Handle(PessoaDeleteCommand request, CancellationToken cancellationToken)
        {
            var pessoa = await _appDbContext.Pessoas.FindAsync(request.Id);

            if (pessoa is null)
            {
                return(OperationResult <PessoaEntity> .CreateFailure("Pessoa não encontrada"));
            }

            _appDbContext.Pessoas.Remove(pessoa);
            await _appDbContext.SaveChangesAsync();

            return(OperationResult <PessoaEntity> .CreateSuccessResult(pessoa));
        }
示例#3
0
        public Task <string> Handle(PessoaDeleteCommand request, CancellationToken cancellationToken)
        {
            var pessoa = domainService.GetId(Guid.Parse(request.Id));

            domainService.Delete(pessoa);
            mediator.Publish(new PessoaNotification
            {
                Pessoa   = pessoa,
                Action   = ActionNotification.Excluido,
                DataHora = DateTime.Now
            });

            return(Task.FromResult($"{pessoa.Nome} {pessoa.Sobrenome} foi excluido do sistama com sucesso."));
        }
示例#4
0
        public async Task <IActionResult> Delete(string id)
        {
            try
            {
                var command = new PessoaDeleteCommand {
                    Id = id
                };
                var result = await pessoaApplicationService.Delete(command);

                return(Ok(result));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
        public async Task <string> Handle(PessoaDeleteCommand request, CancellationToken cancellationToken)
        {
            var client = await _PessoaRepository.GetById(request.Id);

            await _PessoaRepository.Delete(request.Id);

            await _mediator.Publish(new PessoaActionNotification
            {
                Nome     = client.Nome,
                Telefone = client.Telefone,
                Idade    = client.Idade,
                CPF      = client.CPF,
                Action   = ActionNotification.Excluido
            }, cancellationToken);

            return(await Task.FromResult("Cliente excluido com sucesso"));
        }
示例#6
0
 public Task <string> Delete(PessoaDeleteCommand command)
 {
     return(mediator.Send(command));
 }