public async Task <IEnumerable <BlackListModel> > ObterTodosPaginadoAsync(BlackListModel t, int?u) { var p = new DynamicParameters(); p.Add("ClienteID", t.Cliente.ClienteID, DbType.Int32, ParameterDirection.Input); p.Add("Search", t.Search, DbType.String, ParameterDirection.Input); if (t.PaginaAtual.HasValue) { if (t.PaginaAtual.Value == 0) { t.PaginaAtual = 1; } } else { t.PaginaAtual = 1; } var result = await DALGeneric.GenericReturnAsync <dynamic>(string.Format("SELECT CELULAR, DATA, BLACKLISTID FROM CELULAR_BLACKLIST WHERE CLIENTEID=@ClienteID {0} ORDER BY DATA DESC", !string.IsNullOrEmpty(t.Search) ? "AND CAST(CELULAR AS VARCHAR(11)) LIKE '%'+@Search+'%'" : string.Empty), d : p); if (result.Any()) { var dados = result.Select(a => new BlackListModel() { Cliente = t.Cliente, Celular = a.CELULAR, Data = a.DATA, BlacklistID = a.BLACKLISTID, Registros = result.Count(), Paginas = result.Count() / t.Registros }) .Skip((t.PaginaAtual.Value - 1) * t.Registros) .Take(t.Registros); return(dados); } return(null); }
public async Task <IEnumerable <PrefixoModel> > ObterTodos() => await DALGeneric.GenericReturnAsync <PrefixoModel>("SELECT PREFIXO, OPERADORAID OPERADORA FROM HELPER.dbo.PREFIXO");