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

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

            return((new PotsContext(connectionString)).createPot(pot));
        }
Esempio n. 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);
        }
Esempio n. 3
0
 public int?createPotter(Potters potter)
 {
     return((new PottersContext(connectionString)).createPotter(potter));
 }