public string insertPicture(MongoPicture img) { try { string databaseName = "PhotosDB"; var thePictureDB = client.GetDatabase(databaseName); string theCollectionName = "Pictures"; thePictureDB.GetCollection <MongoPicture>(theCollectionName).InsertOne(img); return(img.id.ToString()); } catch (Exception) { return(""); } }
public int addProduct(Product new_pd, MongoPicture img) { getConnection(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = connection; cmd.CommandText = String.Format("insert into shop.product (name, description, price, units, photo_id) values (" + "'" + new_pd.name + "'," + "'" + new_pd.description + "'," + "'" + new_pd.price + "'," + "'" + new_pd.units + "'," + "'" + new_pd.img_id + "');"); int mod = cmd.ExecuteNonQuery(); connection.Close(); return(mod); }