Beispiel #1
0
        public int?createPot(Pots pot)
        {
            Potters potter = this.getPotterById(pot.PottersId);

            if (potter == null)
            {
                return(null);
            }

            return((new PotsContext(connectionString)).createPot(pot));
        }
Beispiel #2
0
        public int?createPotter(Potters potter)
        {
            (int?id, String name, String country) = potter;

            using (MySqlConnection conn = getConnection())
            {
                conn.Open();
                MySqlCommand command = new MySqlCommand("insert into potters (Name, Country) values (?name, ?country)", conn);
                command.Parameters.AddWithValue("?name", name);
                command.Parameters.AddWithValue("?country", country);
                int affected = command.ExecuteNonQuery();
                if (affected == 1)
                {
                    return((int)command.LastInsertedId);
                }
                conn.Close();
            }

            return(null);
        }
Beispiel #3
0
 public int?createPotter(Potters potter)
 {
     return((new PottersContext(connectionString)).createPotter(potter));
 }