示例#1
0
        public async Task <Gamespace[]> List(GamespaceSearch search, string subjectId, bool sudo, CancellationToken ct = default(CancellationToken))
        {
            var query = (sudo && search.WantsAll)
                ? _store.List(search.Term)
                : _store.ListByUser(subjectId)
            ;

            if (search.WantsActive)
            {
                var ts = DateTimeOffset.UtcNow;
                query = query.Where(g =>
                                    g.EndTime <DateTimeOffset.MinValue.AddDays(1) &&
                                               g.ExpirationTime> ts
                                    );
            }

            query = query.OrderByDescending(g => g.WhenCreated);

            if (search.Skip > 0)
            {
                query = query.Skip(search.Skip);
            }

            if (search.Take > 0)
            {
                query = query.Take(search.Take);
            }

            return(Mapper.Map <Gamespace[]>(
                       await query.ToArrayAsync()
                       ));
        }
        public async Task <ActionResult <Gamespace[]> > ListGamespaces([FromQuery] GamespaceSearch model, CancellationToken ct)
        {
            await Validate(model);

            AuthorizeAll();

            return(Ok(
                       await _svc.List(model, Actor.Id, Actor.IsAdmin, ct)
                       ));
        }
 private async Task _validate(GamespaceSearch model)
 {
     await Task.CompletedTask;
 }