Exemple #1
0
        public List <ProdutoDTO> FindProdutos <KProperty>(string texto, Expression <Func <Produto, KProperty> > orderByExpression, bool ascending, int pageIndex, int pageCount)
        {
            try
            {
                if (pageIndex <= 0 || pageCount <= 0)
                {
                    throw new Exception("Argumentos da paginação inválidos.");
                }

                var            spec     = ProdutoSpecifications.ConsultaProduto(texto);
                List <Produto> Produtos = _produtoRepository.GetPaged <KProperty>(pageIndex, pageCount, spec, orderByExpression, ascending).ToList();

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <List <Produto>, List <ProdutoDTO> >(Produtos));
            }
            catch (ApplicationValidationErrorsException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                LoggerFactory.CreateLog().LogError(ex);
                throw new Exception("O servidor não respondeu.");
            }
        }
Exemple #2
0
 public long CountProdutos(string texto)
 {
     try
     {
         var spec = ProdutoSpecifications.ConsultaProduto(texto);
         return(_produtoRepository.Count(spec));
     }
     catch (ApplicationValidationErrorsException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         LoggerFactory.CreateLog().LogError(ex);
         throw new Exception("O servidor não respondeu.");
     }
 }
Exemple #3
0
        public List <ProdutoDTO> FindProdutos <KProperty>(string texto, Expression <Func <Produto, KProperty> > orderByExpression, bool ascending = true)
        {
            try
            {
                var            spec     = ProdutoSpecifications.ConsultaProduto(texto);
                List <Produto> Produtos = _produtoRepository.AllMatching <KProperty>(spec, orderByExpression, ascending).ToList();

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <List <Produto>, List <ProdutoDTO> >(Produtos));
            }
            catch (ApplicationValidationErrorsException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                LoggerFactory.CreateLog().LogError(ex);
                throw new Exception("O servidor não respondeu.");
            }
        }