Esempio n. 1
0
        public IActionResult GetPairs(Guid worldId)
        {
            if (!worlds.Find(worldId, out var world))
            {
                return(NotFound());
            }

            if (!Permissions.AccessWorld(world))
            {
                return(NotFound());
            }

            var pairs = worlds.Pairs(world);

            return(Ok(pairs.All));
        }
Esempio n. 2
0
        public IActionResult GetWorlds(Guid?accountId)
        {
            var src = worlds.NotDeleted;

            if (accountId.HasValue)
            {
                src = from world in src
                      where world.Account.Guid == accountId
                      select world;
            }

            var list = from world in src.ToList()
                       where Permissions.AccessWorld(world)
                       select world;

            return(Ok(list));
        }
        public IActionResult GetPairings(Guid worldId)
        {
            if (!worlds.Find(worldId, out var world))
            {
                return(NotFound());
            }

            if (!Permissions.AccessWorld(world))
            {
                return(NotFound());
            }

            var pairings = worlds.Pairings(world);

            var list = pairings.All.Where(p => p.Date > DateTime.UtcNow);

            return(Ok(list));
        }
Esempio n. 4
0
        public IActionResult GetWorldDescription(Guid?accountId, Guid id)
        {
            if (!worlds.Include(w => w.Description).Find(id, out var world))
            {
                return(NotFound());
            }

            if (!Permissions.AccessWorld(world))
            {
                return(NotFound());
            }

            if (accountId.HasValue && world.Account.Guid != accountId.Value)
            {
                return(NotFound());
            }

            return(Ok(world.Description));
        }
Esempio n. 5
0
        public IActionResult GetWorld(Guid?accountId, string identifier)
        {
            Optional <World> value;

            if (Guid.TryParse(identifier, out var guid))
            {
                value = worlds.Find(guid);
            }
            else
            {
                value = worlds.Find(new Identifier(identifier));
            }

            if (!value.Exists(out World world))
            {
                return(NotFound());
            }

            if (accountId.HasValue && world.Account.Guid != accountId.Value)
            {
                return(NotFound());
            }

            if (Auth != null && Permissions.AccessWorld(world))
            {
                return(Ok(world));
            }

            worlds.Entry(world)
            .LoadRelations(w => w.Description.Faq);

            return(Ok(new {
                id = world.Guid,
                identifier = world.Identifier,
                name = world.Name,
                privacy = world.Privacy,
                description = world.Description
            }));
        }