public async Task <IList <IPTU> > GetByImpostoQuery(ImpostoQuery impostoQuery)
        {
            try
            {
                var data = dbContext.IPTUs.Where(w =>
                                                 (!string.IsNullOrEmpty(impostoQuery.CPFouCNPJ) ? impostoQuery.CPFouCNPJ == w.CPFOuCNPJ : true) &&
                                                 (!string.IsNullOrEmpty(impostoQuery.InscricaoImovel) ? impostoQuery.InscricaoImovel == w.InscricaoImovel : true) &&
                                                 (impostoQuery.DataConsulta.HasValue ? impostoQuery.DataConsulta >= w.DataVencimento : true));

                return(await data.ToListAsync());
            }
            catch (System.Exception ex)
            {
                var innerEx = (ex.InnerException != null) ? ex.InnerException.Message : "";

                var excecao = $" {dbContext.Database.GetConnectionString()} \n {ex.Message} \n {innerEx} ";
                throw new System.Exception(excecao);
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Consulta(ImpostoQuery consulta)
        {
            if (!consulta.IsValid())
            {
                return(BadRequest(consulta.Errors()));
            }

            var retorno = await iPTURepository.GetByImpostoQuery(consulta);

            return(Ok(retorno));

            // try
            // {

            // }
            // catch (System.Exception ex)
            // {
            //     return BadRequest($"${ex.Message} \n ${ex.StackTrace}");
            // }
        }