Exemplo n.º 1
0
        public GuildQuery ListGuilds(string authKey)
        {
            if (!_apiRepository.ValidateAuthKey(authKey))
            {
                return(new GuildQuery()
                {
                    StatusCode = HttpStatusCode.Unauthorized,
                    Guilds = new List <Guild>()
                    {
                        new Guild()
                        {
                            Name = "Unauthorized"
                        }
                    }
                });
            }

            var returnValue = new GuildQuery();

            var guilds = _guildRepository.GetApprovedGuilds();

            foreach (var guild in guilds)
            {
                returnValue.Guilds.Add(new Guild()
                {
                    Id     = guild.Id,
                    Name   = guild.Name,
                    Shard  = guild.Shard.Name,
                    Region = guild.Shard.Region
                });
            }

            return(returnValue);
        }
Exemplo n.º 2
0
        public override async Task <Result> Delete(GuildQuery request, ServerCallContext context)
        {
            var result = await _database.DeleteGuildAsync(request.Id);

            return(new Result {
                Status = result.Success ? Status.Success : Status.Failed
            });
        }
Exemplo n.º 3
0
        public GuildQuery Guild(string authKey, string name)
        {
            if (!_apiRepository.ValidateAuthKey(authKey))
            {
                return(new GuildQuery()
                {
                    StatusCode = HttpStatusCode.Unauthorized,
                    Guilds = new List <Guild>()
                    {
                        new Guild()
                        {
                            Name = "Unauthorized"
                        }
                    }
                });
            }

            var returnValue = new GuildQuery();
            var guild       = _guildRepository.Get(name);

            if (guild == null)
            {
                returnValue.Guilds.Add(new Guild()
                {
                    Id     = 0,
                    Name   = "GuildNotFound",
                    Shard  = "N/A",
                    Region = "N/A"
                });
            }
            else
            {
                returnValue.Guilds.Add(new Guild()
                {
                    Id     = guild.Id,
                    Name   = guild.Name,
                    Shard  = guild.Shard.Name,
                    Region = guild.Shard.Region
                });
            }
            return(returnValue);
        }
Exemplo n.º 4
0
        public override async Task <GuildResult> Get(GuildQuery request, ServerCallContext context)
        {
            var result = await _database.GetGuildAsync(request.Id);

            if (!result.Success)
            {
                return(new GuildResult {
                    Status = Status.Failed
                });
            }

            var output = new GuildResult
            {
                Status = Status.Success
            };

            if (result.Value is not null)
            {
                output.Data = JsonSerializer.Serialize(result.Value);
            }

            return(output);
        }