Ejemplo n.º 1
0
        public async Task <ActionResult <PessoaViewModel> > Excluir([FromRoute] Guid id)
        {
            var pessoaViewModel = await _pesssoaRepository.ObterPessoa(id);

            if (pessoaViewModel == null)
            {
                return(NotFound());
            }

            var estacionamento = await _estacionamentoRepository.ObterEstabelicimentoPorPessoa(id);

            if (estacionamento != null)
            {
                NotificarErro("Este manobrista não pode ser deletado.");
                return(CustomResponse(pessoaViewModel));
            }

            try
            {
                await _pessoaService.Remover(id);
            }
            catch (Exception e)
            {
                throw;
            }

            return(CustomResponse(pessoaViewModel));
        }