public List <UsuarioDTO> FindUsuarios <KProperty>(string texto, Expression <Func <Usuario, 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 = UsuarioSpecifications.ConsultaTexto(texto); List <Usuario> usuarios = _usuarioRepository.GetPaged <KProperty>(pageIndex, pageCount, spec, orderByExpression, ascending).ToList(); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <List <Usuario>, List <UsuarioDTO> >(usuarios)); } catch (ApplicationValidationErrorsException ex) { throw ex; } catch (Exception ex) { LoggerFactory.CreateLog().LogError(ex); throw new Exception("O servidor não respondeu."); } }
public long CountUsuarios(string texto) { try { var spec = UsuarioSpecifications.ConsultaTexto(texto); return(_usuarioRepository.Count(spec)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
public List <UsuarioListDTO> FindUsuarios <KProperty>(string texto, Expression <Func <Usuario, KProperty> > orderByExpression, bool ascending, int pageIndex, int pageCount) { try { var spec = UsuarioSpecifications.ConsultaTexto(texto); List <Usuario> usuarios = _usuarioRepository.GetPaged <KProperty>(pageIndex, pageCount, spec, orderByExpression, ascending).ToList(); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <List <Usuario>, List <UsuarioListDTO> >(usuarios)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
public long CountUsuarios(string texto) { try { var spec = UsuarioSpecifications.ConsultaTexto(texto); return(_usuarioRepository.Count(spec)); } catch (ApplicationValidationErrorsException ex) { throw ex; } catch (Exception ex) { LoggerFactory.CreateLog().LogError(ex); throw new Exception("O servidor não respondeu."); } }
public List <UsuarioDTO> FindUsuarios <KProperty>(string texto, Expression <Func <Usuario, KProperty> > orderByExpression, bool ascending = true) { try { var spec = UsuarioSpecifications.ConsultaTexto(texto); List <Usuario> usuarios = _usuarioRepository.AllMatching <KProperty>(spec, orderByExpression, ascending).ToList(); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <List <Usuario>, List <UsuarioDTO> >(usuarios)); } catch (ApplicationValidationErrorsException ex) { throw ex; } catch (Exception ex) { LoggerFactory.CreateLog().LogError(ex); throw new Exception("O servidor não respondeu."); } }