Exemplo n.º 1
0
        public async Task <Tuple <List <User>, InfoPagination> > GetFilteredAndPagined(int take, int skip, string filter)
        {
            if (filter == null)
            {
                filter = string.Empty;
            }

            var users = await _userAccess.Execute <UserFiltered>("GetUserPaginedAndFiltered", new { @take = take, @skip = skip, @filter = filter });

            Tuple <List <User>, InfoPagination> pagination;

            if (users.Any())
            {
                pagination =
                    new Tuple <List <User>, InfoPagination>(users.Select(g => new User
                {
                    Email      = g.Email,
                    FirstName  = g.FirstName,
                    LastName   = g.LastName,
                    isActive   = g.isActive,
                    RoleId     = g.RoleId,
                    Updated    = g.Updated,
                    UserId     = g.UserId,
                    UserName   = g.UserName,
                    Token      = g.Token,
                    LanguageId = g.LanguageId,
                    Created    = g.Created
                }).ToList(), new InfoPagination {
                    Take = users.First().Take, Skip = users.First().Skip, Filter = users.First().Filter, Total = users.First().Total
                });
            }
            else
            {
                pagination =
                    new Tuple <List <User>, InfoPagination>(new List <User> {
                    new User()
                }, new InfoPagination {
                    Take = 0, Skip = 0, Filter = "", Total = 0
                });
            }

            return(pagination);
        }