public async Task Add(HttpCharacterModel model)
 {
     if (_testConnection != null)
     {
         await Add(model, _testConnection);
     }
     else
     {
         using (var conn = new SqliteConnection(_connectionString))
             await Add(model, conn);
     }
 }
        private static async Task Add(HttpCharacterModel model, SqliteConnection connection)
        {
            var command = connection.CreateCommand();

            command.CommandText =
                "INSERT INTO add2 (Name) " +
                "VALUES ($name)";
            command.Parameters.AddWithValue("$name", model.Name);
            await connection.OpenAsync();

            await command.ExecuteNonQueryAsync();
        }
 public async Task Update(int id, HttpCharacterModel model)
 {
     if (string.IsNullOrEmpty(await Get(id).Name()))
     {
         await Add(model);
     }
     else
     {
         if (_testConnection != null)
         {
             await Update(id, model, _testConnection);
         }
         else
         {
             using (var conn = new SqliteConnection(_connectionString))
                 await Update(id, model, conn);
         }
     }
 }
        private static async Task Update(int id, HttpCharacterModel model, SqliteConnection connection)
        {
            var command = connection.CreateCommand();

            command.CommandText = "UPDATE add2 SET Name = $name, " +
                                  "Str = $str, " +
                                  "Dex = $dex, " +
                                  "Con = $con, " +
                                  "Int = $int, " +
                                  "Wis = $wis, " +
                                  "Chr = $chr, " +
                                  "Race = $race, " +
                                  "AvailableRaces = $availableRaces, " +
                                  "Gender = $gender, " +
                                  "Height = $height, " +
                                  "Weight = $weight, " +
                                  "Age = $age, " +
                                  "Class = $className, " +
                                  "AvailableClasses = $availableClasses, " +
                                  "Alignment = $alignment, " +
                                  "AvailableAlignments = $availableAlignments, " +
                                  "HP = $hp, " +
                                  "Paralyze = $paralyze, " +
                                  "Rod = $rod, " +
                                  "Petrification = $petrification, " +
                                  "Breath = $breath, " +
                                  "Spell = $spell, " +
                                  "MoveRate = $moveRate, " +
                                  "Funds = $funds, " +
                                  "CompletionStep = $completionStep " +
                                  "WHERE Id = $id";
            command.Parameters.AddWithValue("$id", id);
            command.Parameters.AddWithValue("$name", model.Name);
            command.Parameters.AddWithValue("$str", model.Str);
            command.Parameters.AddWithValue("$dex", model.Dex);
            command.Parameters.AddWithValue("$con", model.Con);
            command.Parameters.AddWithValue("$int", model.Int);
            command.Parameters.AddWithValue("$wis", model.Wis);
            command.Parameters.AddWithValue("$chr", model.Chr);
            command.Parameters.AddWithValue("$race", model.Race ?? "none");
            command.Parameters.AddWithValue("$availableRaces",
                                            model.AvailableRaces == null ? "none" : string.Join(",", model.AvailableRaces));
            command.Parameters.AddWithValue("$gender", model.Gender ?? "n");
            command.Parameters.AddWithValue("$height", model.Height);
            command.Parameters.AddWithValue("$weight", model.Weight);
            command.Parameters.AddWithValue("$age", model.Age);
            command.Parameters.AddWithValue("$className", model.ClassName ?? "none");
            command.Parameters.AddWithValue("$availableClasses",
                                            model.AvailableClasses == null ? "none" : string.Join(",", model.AvailableClasses));
            command.Parameters.AddWithValue("$alignment", model.Alignment ?? "none");
            command.Parameters.AddWithValue("$availableAlignments",
                                            model.AvailableAlignments == null ? "none" : string.Join(",", model.AvailableAlignments));
            command.Parameters.AddWithValue("$hp", model.HP);
            command.Parameters.AddWithValue("$paralyze", model.Paralyze);
            command.Parameters.AddWithValue("$rod", model.Rod);
            command.Parameters.AddWithValue("$petrification", model.Petrification);
            command.Parameters.AddWithValue("$breath", model.Breath);
            command.Parameters.AddWithValue("$spell", model.Spell);
            command.Parameters.AddWithValue("$moveRate", model.MoveRate);
            command.Parameters.AddWithValue("$funds", model.Funds);
            command.Parameters.AddWithValue("$completionStep", model.CompletionStep);
            await connection.OpenAsync();

            await command.ExecuteNonQueryAsync();
        }