Example #1
0
        public IEnumerable <EnderecoModel> GetComParametro(EnderecoQO endereco)
        {
            try
            {
                if (endereco.PessoaId != 0)
                {
                    var where = $"PESSOA_ID = {endereco.PessoaId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where)))
                    {
                        throw new Exception();
                    }

                    return(EnderecoRepository.ListPorPessoaId(endereco.PessoaId));
                }
                else
                {
                    List <EnderecoModel> listEndereco = new List <EnderecoModel>();

                    listEndereco.Add(EnderecoRepository.Find(endereco.EnderecoId));

                    return(listEndereco);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        public void DeleteComParametro(EnderecoQO endereco)
        {
            try
            {
                if (endereco.PessoaId != 0)
                {
                    var where = $"PESSOA_ID = {endereco.PessoaId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("PESSOA_ID", "T_ORCA_PESSOA", where)))
                    {
                        throw new Exception();
                    }

                    EnderecoRepository.DeletePorPessoaId(endereco.PessoaId);
                }
                else
                {
                    var where = $"ENDERECO_ID = {endereco.EnderecoId}";
                    if (string.IsNullOrEmpty(MetodosGenericosService.DlookupOrcamentaria("ENDERECO_ID", "T_ORCA_ENDERECO", where)))
                    {
                        throw new Exception();
                    }

                    EnderecoRepository.Delete(endereco.EnderecoId);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }