Esempio n. 1
0
        public async Task <ActionResult <IEnumerable <UserViewModel> > > GetUsers(
            [FromQuery] int offset = 0,
            [FromQuery] int limit  = 100)
        {
            var users = await database.GetAll <UserModel>()
                        .OrderByDescending(t => t.Created)
                        .Skip(offset)
                        .Take(limit)
                        .Select(u => new UserViewModel(u))
                        .ToListAsync();

            return(Ok(users));
        }
Esempio n. 2
0
        public async Task <ActionResult <IEnumerable <LinkViewModel> > > GetLinks(
            [FromQuery] int offset = 0,
            [FromQuery] int limit  = 100)
        {
            var canViewLinks = AuthorizedUser.HasPermissions(Permissions.VIEW_LINKS);

            var links = await database.GetAll <LinkModel>()
                        .Where(l => canViewLinks || l.Creator.Guid == AuthorizedUser.Guid)
                        .OrderByDescending(t => t.Created)
                        .Skip(offset)
                        .Take(limit)
                        .Select(l => new LinkViewModel(l, AuthorizedUser))
                        .ToListAsync();

            return(Ok(links));
        }