public bool RemoveProduct(Product product) { if (DatabaseManager.DeleteProduct(product)) { return true; } else { return false; } }
public bool UpdateProduct(Product product, Account account) { if(DatabaseManager.ModifyProduct(product, account)) { return true; } else { return false; } }
public bool CreateProduct(Product product, Account account) { Product tempProduct = DatabaseManager.CreateProduct(product, account); if (tempProduct != null) { this.Products = RequestProducts(); return true; } else { return false; } }
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(); } } }
public static Account ProductModifiedBy(Product product) { { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "SELECT ID, EMAIL, WACHTWOORD, NAAM, ROL FROM GEBRUIKER, GROEP_GEBRUIKERS WHERE ID = WIJZIGINGEN.GEBRUIKER_ID AND WIJZIGINGEN.PRODUCT_ID = :productID;"); command.Parameters.Add(":ProductD", product.ID); OracleDataReader reader = ExecuteQuery(command); if (!reader.HasRows) { return null; } reader.Read(); return ParseAccount(reader); } finally { connection.Close(); } } } }
public static bool ModifyProduct(Product product, Account account) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, "UPDATE PRODUCT SET naam = :name, prijs = :price, imgurl = :imageURL, laastgewijzigd = :lastModified"); command.Parameters.Add(":name", product.Name); command.Parameters.Add(":price", product.Price); command.Parameters.Add("imageURL", product.ImageURL); command.Parameters.Add(":lastModified", product.LastModified); bool isAdded = ExecuteNonQuery(command); if (!isAdded) { throw new Exception("The product could not be updated in the database."); } OracleCommand modCommand = CreateOracleCommand(connection, "INSERT INTO WIJZIGINGEN(ID, PRODUCT_ID, GEBRUIKER_ID, WIJZING, DATUM) VALUES(SEQ_WIJZIGINGID.NEXTVAL, :productID, :accountID, :description, :date"); modCommand.Parameters.Add(":productID", product.ID); modCommand.Parameters.Add(":accountID", account.ID); modCommand.Parameters.Add(":change", null); modCommand.Parameters.Add(":date", product.LastModified); return ExecuteNonQuery(modCommand); } finally { connection.Close(); } } }
public static bool DeleteProduct(Product product) { using (OracleConnection connection = Connection) { try { OracleCommand command = CreateOracleCommand(connection, ""); return true; } catch { return false; } finally { connection.Close(); } } }