private static async Task <GetSettingsResponse> GetServerSettingsOfUser(User user)
        {
            QueryResponse response = await GetServerSettingBySpecificProperty("UserUuid", user.Uuid);

            List <ServerSetting> serverSettings = new List <ServerSetting>();

            response.Items.ForEach(item =>
            {
                ServerSetting serverSetting = ServerSetting.FromDynamoDbDictionary(item);
                serverSetting.IsRunning     = SDaysTDieServerHandler.IsServerRunningBySeed(serverSetting.WorldGenSeed);
                serverSettings.Add(serverSetting);
            });
            return(new GetSettingsResponse(GetSettingsResult.OK, serverSettings));
        }
        private static async Task <ModifySettingsResponse> EditServerSetting(ServerSetting serverSettings, User user, string token)
        {
            ServerSetting dbServerSetting = await AmazonDynamoDBFactory.ExecuteInTransactionContext(async (client, context) =>
            {
                serverSettings.TableId = TABLE_ID;
                return(await context.LoadAsync(serverSettings));
            });

            return(await AmazonDynamoDBFactory.ExecuteInTransactionContext(async (client, context) =>
            {
                try
                {
                    if (dbServerSetting == null)
                    {
                        return new ModifySettingsResponse(ModifySettingsResult.SETTING_NOT_FOUND);
                    }
                    if (SDaysTDieServerHandler.IsServerRunningBySeed(dbServerSetting.WorldGenSeed))
                    {
                        return new ModifySettingsResponse(ModifySettingsResult.SERVER_MUST_BE_STOPPED);
                    }
                    QueryResponse response = await GetServerSettingBySpecificProperty("WorldGenSeed", serverSettings.WorldGenSeed);
                    if (response.Items.Count > 0 && Convert.ToInt32(response.Items[0]["Id"].N.ToString()) != dbServerSetting.Id)
                    {
                        return new ModifySettingsResponse(ModifySettingsResult.GAME_SEED_ALREADY_EXISTS);
                    }
                    string oldUserId = dbServerSetting.UserUuid;
                    GetUsersResponse getUsersResponse = await BesteUser.GetUser(JsonConvert.SerializeObject(user, Formatting.None, new JsonSerializerSettings {
                        NullValueHandling = NullValueHandling.Ignore
                    }));
                    if (getUsersResponse.Result != GetUsersResult.SUCCESS)
                    {
                        return new ModifySettingsResponse(ModifySettingsResult.USER_NOT_FOUND);
                    }
                    User dbUser = getUsersResponse.Users[0];
                    serverSettings.UserUuid = dbUser.Uuid;
                    serverSettings.CopyAllButId(dbServerSetting);
                    if (oldUserId != getUsersResponse.Users[0].Uuid)
                    {
                        await AddOrUpdateServerSettingRight("EditServerSettings", serverSettings.Id, dbUser.Uuid, token);
                    }
                    await context.SaveAsync(dbServerSetting);
                    return new ModifySettingsResponse(ModifySettingsResult.SETTING_EDITED);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString() + "\n" + ex.StackTrace);
                    return new ModifySettingsResponse(ModifySettingsResult.EXCEPTION);
                }
            }));
        }
        private static async Task <ModifySettingsResponse> DeleteServerSetting(ServerSetting serverSettings, User user, string connectedUserToken)
        {
            ServerSetting dbServerSetting = await AmazonDynamoDBFactory.ExecuteInTransactionContext(async (client, context) =>
            {
                serverSettings.TableId = TABLE_ID;
                return(await context.LoadAsync(serverSettings));
            });

            return(await AmazonDynamoDBFactory.ExecuteInTransactionContext(async (client, context) =>
            {
                try
                {
                    if (dbServerSetting == null)
                    {
                        return new ModifySettingsResponse(ModifySettingsResult.SETTING_NOT_FOUND);
                    }
                    if (SDaysTDieServerHandler.IsServerRunningBySeed(dbServerSetting.WorldGenSeed))
                    {
                        return new ModifySettingsResponse(ModifySettingsResult.SERVER_MUST_BE_STOPPED);
                    }
                    await AmazonDynamoDBFactory.ExecuteInTransactionContext(async(clientDelete, contextDelete) =>
                    {
                        await contextDelete.DeleteAsync(dbServerSetting);
                    });
                    await AmazonDynamoDBFactory.ExecuteInTransactionContext(async(clientDelete, contextDelete) =>
                    {
                        await DeleteAllRightsByServerSettingId(dbServerSetting.Id);
                    });
                    return new ModifySettingsResponse(ModifySettingsResult.SETTING_DELETED);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString() + "\n" + ex.StackTrace);
                    return new ModifySettingsResponse(ModifySettingsResult.EXCEPTION);
                }
            }));
        }