public IEnumerable <Boleto> FiltrarBoletos(BoletoFilter filter, bool paginar = false)
        {
            var query = Query();

            if (!string.IsNullOrEmpty(filter.Nome))
            {
                query = query.Where(x => x.Aluno.Nome.Contains(filter.Nome));
            }
            if (!string.IsNullOrEmpty(filter.Numero))
            {
                query = query.Where(x => x.SeuNumero.Contains(filter.Numero));
            }
            if (filter.DataVencimentoDe.HasValue)
            {
                query = query.Where(x => x.DataVencimento >= filter.DataVencimentoDe);
            }
            if (filter.DataVencimentoAte.HasValue)
            {
                query = query.Where(x => x.DataVencimento <= filter.DataVencimentoAte);
            }
            if (filter.DataPagamentoDe.HasValue)
            {
                query = query.Where(x => x.DataPagamento >= filter.DataPagamentoDe);
            }
            if (filter.DataPagamentoAte.HasValue)
            {
                query = query.Where(x => x.DataPagamento <= filter.DataPagamentoAte);
            }

            if (filter.StatusId != null && filter.StatusId.Any())
            {
                query = query.Where(x => filter.StatusId == null || !filter.StatusId.Any() || filter.StatusId.Contains(x.TipoStatusBoletoId));
            }

            if (paginar)
            {
                filter.Total = query.Count();
                return(PaginarResultado(query, filter).ToList());
            }
            else
            {
                return(query.ToList());
            }
        }
Exemple #2
0
 public FilterResultDTO <BoletoDTO> FiltrarBoletos(BoletoFilter filtro)
 {
     try
     {
         IEnumerable <Boleto> boletos = boletoRepository.FiltrarBoletos(filtro, true);
         var retorno = new FilterResultDTO <BoletoDTO>
         {
             Total         = filtro.Total,
             Pagina        = filtro.Pagina,
             TamanhoPagina = filtro.TamanhoPagina,
             Lista         = boletos.Select(x => new BoletoDTO(x))
         };
         return(retorno);
     }
     catch (Exception e)
     {
         log.Error("Erro ao buscar boletos.", e);
         throw new Exception("Erro ao buscar boletos.");
     }
 }
Exemple #3
0
 public FilterResultDTO <BoletoDTO> FiltrarBoletos(BoletoFilter filter)
 {
     return(boletoService.FiltrarBoletos(filter));
 }