internal bool UpdateQuantidadeIngredienteMontagemPizza(MontagemPizza montagemPizza) { try { using (SQLiteConnection connection = new SQLiteConnection(sqlitecon)) { connection.Open(); string query = string.Format("UPDATE MONTAGEMPIZZA SET QNT_INGREDIENTE = @QNT_INGREDIENTE WHERE ID_PIZZA = @ID_PIZZA AND ID_INGREDIENTE = @ID_INGREDIENTE"); using (SQLiteCommand cmd = new SQLiteCommand(query, connection)) { cmd.Parameters.AddWithValue("@QNT_INGREDIENTE", montagemPizza.Qnt_Ingrediente); cmd.Parameters.AddWithValue("@ID_PIZZA", montagemPizza.Id_Pizza); cmd.Parameters.AddWithValue("@ID_INGREDIENTE", montagemPizza.Id_Ingrediente); return(cmd.ExecuteNonQuery() > 0 ? true : false); } } } catch (SQLiteException e) { throw; } }
internal bool InsertMontagemPizza(MontagemPizza montagemPizza) { try { using (SQLiteConnection connection = new SQLiteConnection(sqlitecon)) { connection.Open(); string query = string.Format("INSERT INTO MONTAGEMPIZZA VALUES(@ID_PIZZA, @ID_INGREDIENTE, @QNT_INGREDIENTE)", montagemPizza.Id_Pizza, montagemPizza.Id_Ingrediente, montagemPizza.Qnt_Ingrediente); using (SQLiteCommand cmd = new SQLiteCommand(query, connection)) { cmd.Parameters.AddWithValue("@ID_PIZZA", montagemPizza.Id_Pizza); cmd.Parameters.AddWithValue("@ID_INGREDIENTE", montagemPizza.Id_Ingrediente); cmd.Parameters.AddWithValue("@QNT_INGREDIENTE", montagemPizza.Qnt_Ingrediente); return(cmd.ExecuteNonQuery() > 0 ? true : false); } } } catch (SQLiteException e) { throw; } }
private bool ValidaMontagemPizza(MontagemPizza montagemPizza) { if (montagemPizza.Id_Ingrediente <= 0 || montagemPizza.Id_Pizza <= 0 || montagemPizza.Qnt_Ingrediente <= 0) { return(false); } else { return(true); } }
public bool InserirMontagemPizza(MontagemPizza montagemPizza) { try { bool retorno = false; if (ValidaMontagemPizza(montagemPizza)) { retorno = repositorioMontagemPizza.InsertMontagemPizza(montagemPizza); } return(retorno); } catch (Exception e) { throw; } }