public static Product AddProductToGroceryList(Product product, Account account, GroceryList groceries)
        {
            using (OracleConnection connection = Connection)
            {
                try
                {
                    OracleCommand command = CreateOracleCommand(connection, "Insert INTO BOODSCHAPPENLIJST_PRODUCTEN(BOODSCHAPPENLIJST_ID, PRODUCT_ID, GEBRUIKER_ID) VALUES(:groceriesID, :productID, :accountID");
                    command.Parameters.Add(":groceriesID", groceries.ID);
                    command.Parameters.Add(":productID", product.ID);
                    command.Parameters.Add(":accountID", account.ID);

                    command.ExecuteNonQuery();
                    return product;
                }
                catch
                {
                    return null;
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Esempio n. 2
0
        public static Product AddProductToGroceryList(Product product, Account account, GroceryList groceries)
        {
            using (OracleConnection connection = Connection)
            {
                try
                {
                    OracleCommand command = CreateOracleCommand(connection, "Insert INTO BOODSCHAPPENLIJST_PRODUCTEN(BOODSCHAPPENLIJST_ID, PRODUCT_ID, GEBRUIKER_ID) VALUES(:groceriesID, :productID, :accountID");
                    command.Parameters.Add(":groceriesID", groceries.ID);
                    command.Parameters.Add(":productID", product.ID);
                    command.Parameters.Add(":accountID", account.ID);

                    command.ExecuteNonQuery();
                    return(product);
                }
                catch
                {
                    return(null);
                }
                finally
                {
                    connection.Close();
                }
            }
        }