public ActionResult GetById(int id)
        {
            var endereco = _repositorio.ObterPorId(id);

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

            return(Ok(endereco));
        }
Exemplo n.º 2
0
        public void Endereco_InfraData_PegarPorID_EsperadoOK()
        {
            //cenário
            BaseSqlTeste.SemearBancoParaEndereco();
            _endereco.ID = 1;

            //Ação
            Endereco endereco = _enderecoRepositorio.ObterPorId(_endereco.ID);

            //Verificação
            endereco.Should().NotBeNull();
            endereco.ID.Should().Be(_endereco.ID);
        }
        public void InfraData_Deletar_deve_deletar_um_endereco()
        {
            //Cenário
            int      idPesquisa = 1;
            Endereco cliente    = _enderecoRepositorio.ObterPorId(idPesquisa);

            //Ação
            _enderecoRepositorio.Deletar(cliente);

            //Verifica
            Endereco resultado = _enderecoRepositorio.ObterPorId(idPesquisa);

            resultado.Should().BeNull();
        }
Exemplo n.º 4
0
        public async Task <ActionResult> ObterPorId(int EnderecoId)
        {
            try
            {
                var enderecos = await _enderecoRepositorio.ObterPorId(EnderecoId);

                var results = _mapper.Map <EnderecoDto>(enderecos);
                return(Ok(results));
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco de Dados Falou {ex.Message}"));
            }
        }
Exemplo n.º 5
0
        public Destinatario ObterPorId(long id)
        {
            if (id <= 0)
            {
                throw new ExcecaoIdentificadorInvalido();
            }

            var destinatario = _destinatarioRepositorio.ObterPorId(id);

            if (destinatario == null)
            {
                return(null);
            }

            destinatario.Endereco = _enderecoRepositorio.ObterPorId(destinatario.Endereco.ID);

            return(destinatario);
        }
Exemplo n.º 6
0
        public Transportador ObterPorId(long id)
        {
            if (id <= 0)
            {
                throw new ExcecaoIdentificadorInvalido();
            }

            var transportador = _transportadorRepositorio.ObterPorId(id);

            if (transportador == null)
            {
                return(null);
            }

            transportador.Endereco = _enderecoRepositorio.ObterPorId(transportador.Endereco.ID);

            return(transportador);
        }
Exemplo n.º 7
0
        public Endereco ObterPorId(long id)
        {
            if (id <= 0)
            {
                throw new ExcecaoIdentificadorInvalido();
            }

            return(_enderecoRepositorio.ObterPorId(id));
        }
Exemplo n.º 8
0
        public Emitente ObterPorId(long id)
        {
            if (id < 1)
            {
                throw new ExcecaoIdentificadorInvalido();
            }

            var emitente = _emitenteRepositorio.ObterPorId(id);

            if (emitente == null)
            {
                return(null);
            }

            emitente.Endereco = _enderecoRepositorio.ObterPorId(emitente.Endereco.ID);

            return(emitente);
        }
Exemplo n.º 9
0
        public void Endereco_Integracao_Inserir_EsperadoOK()
        {
            _endereco = EnderecoObjetoMae.ObterValido();

            var endereco = _enderecoServico.Inserir(_endereco);

            var enderecoInserido = _enderecoRepositorio.ObterPorId(endereco.ID);

            enderecoInserido.ID.Should().Be(endereco.ID);
            endereco.Numero.Should().Be(_endereco.Numero);
        }
Exemplo n.º 10
0
        public NotaFiscal ObterPorId(long id)
        {
            if (id < 1)
            {
                throw new ExcecaoIdentificadorInvalido();
            }

            var nota = _notaFiscalRepositorio.ObterPorId(id);

            if (nota == null)
            {
                return(null);
            }

            nota.Destinatario          = _destinatarioRepositorio.ObterPorId(nota.Destinatario.ID);
            nota.Destinatario.Endereco = _enderecoRepositorio.ObterPorId(nota.Destinatario.Endereco.ID);

            nota.Emitente          = _emitenteRepositorio.ObterPorId(nota.Emitente.ID);
            nota.Emitente.Endereco = _enderecoRepositorio.ObterPorId(nota.Emitente.Endereco.ID);

            nota.Transportador          = _transportadorRepositorio.ObterPorId(nota.Transportador.ID);
            nota.Transportador.Endereco = _enderecoRepositorio.ObterPorId(nota.Transportador.Endereco.ID);

            return(nota);
        }
Exemplo n.º 11
0
 public async Task <EnderecoViewModel> ObterEnderecoPorId(Guid id)
 {
     return(_mapper.Map <EnderecoViewModel>(await _enderecoRepositorio.ObterPorId(id)));
 }
Exemplo n.º 12
0
 public async Task <Endereco> ObterPorIdAsync(Guid Id)
 {
     return(await enderecoRepositorio.ObterPorId(Id));
 }
Exemplo n.º 13
0
 public Endereco ObterEnderecoPorId(Guid id)
 {
     return(_enderecoRepositorio.ObterPorId(id));
 }