public string Delete(long idproduct, long Idrecipe) { IngredientDAL userdal = new IngredientDAL(); return(userdal.Delete(idproduct, Idrecipe)); }
public List <Ingredient> GetByRecipe(long Idrecipe) { IngredientDAL userdal = new IngredientDAL(); return(userdal.GetByRecipe(Idrecipe)); }
public string Modify(Ingredient user) { IngredientDAL userdal = new IngredientDAL(); return(userdal.Update(user)); }
public List <Ingredient> ExtractAllFromRecipe(long IDRecipe) { IngredientDAL userdal = new IngredientDAL(); return(userdal.GetAllFromRecipe(IDRecipe)); }
public bool DeleteIngredient(int ingredientId) { bool ingredientDeleted = false; try { if (ingredientId > 0) { IngredientDAL ingredientDAL = new IngredientDAL(); ingredientDeleted = ingredientDAL.DeleteIngredient(ingredientId); } else { throw new RecipeIngredientSystemExceptions("Invalid Ingredient ID"); } } catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(ingredientDeleted); }
public List <Ingredient> GetIngredient() { IngredientDAL ingredientDAL = new IngredientDAL(); List <Ingredient> ingredients = ingredientDAL.GetIngredients(); return(ingredients); }
private void ShowAllRecipes() { Console.WriteLine("SHOWING RECIPES"); RecipeDAL dal = new RecipeDAL(connectionString); List <Recipe> allRecipes = dal.GetAllRecipes(); foreach (Recipe r in allRecipes) { Console.WriteLine(); Console.WriteLine(r.Id + ")" + r.Name + " - " + r.CookTimeInMinutes + " minutes"); Console.WriteLine("DESCRIPTION: " + r.Description); IngredientDAL ingredientDal = new IngredientDAL(connectionString); List <Ingredient> recipeIngredients = ingredientDal.GetIngredientsForRecipe(r.Id); Console.WriteLine("INGREDIENTS"); foreach (Ingredient i in recipeIngredients) { Console.WriteLine(" - " + i.Name + " (" + i.Quantity + ")"); } } Console.ReadLine(); }
public string Delete(long ID) { IngredientDAL userdal = new IngredientDAL(); return(userdal.Delete(ID)); }
private void AddIngredient() { string name = CLIHelper.GetString("What is the ingredient"); string quantity = CLIHelper.GetString($"How much of {name}"); int recipeId = CLIHelper.GetInteger("Which recipe is it for"); Ingredient i = new Ingredient(); i.Name = name; i.Quantity = quantity; i.RecipeId = recipeId; IngredientDAL dal = new IngredientDAL(connectionString); dal.AddIngredient(i); Console.WriteLine("SUCCESS"); Console.ReadLine(); }
public Ingredient SearchIngredient(int IngredientId) { Ingredient searchIngredient = null; try { IngredientDAL ingredientDAL = new IngredientDAL(); searchIngredient = ingredientDAL.SearchIngredient(IngredientId); } catch (RecipeIngredientSystemExceptions) { MessageBox.Show("Enter valid IngredientId to search an ingredient."); } catch (Exception ex) { throw ex; } return(searchIngredient); }
public bool ModifyIngredient(Ingredient ingredient) { bool ingredientUpdated = false; try { if (ValidateIngredient(ingredient)) { IngredientDAL ingredientDAL = new IngredientDAL(); ingredientUpdated = ingredientDAL.ModifyIngredient(ingredient); } } catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(ingredientUpdated); }
public void AddIngredientToExistingRecipe() { // Arrange // - Add a Recipe so that we can add ingredients // - Write SQL code to Insert FAKE RECIPE int recipeId; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO recipe VALUES ('Fake Recipe', 'Fake Instructions', 'Fake Description', 0);", conn); cmd.ExecuteNonQuery(); // - Get new recipe Id with SELECT SCOPE_IDENTITY() cmd = new SqlCommand("SELECT CAST(SCOPE_IDENTITY() as int);", conn); recipeId = Convert.ToInt32(cmd.ExecuteScalar()); } // - Create an ingredient to add Ingredient i = new Ingredient(); i.Name = "FAKE INGREDIENT"; i.Quantity = "FAKE QUANTITY"; i.RecipeId = recipeId; // - Create the ingredient DAL IngredientDAL dal = new IngredientDAL(connectionString); // Act // - Call AddIngredient in the IngredientDAL bool output = dal.AddIngredient(i); // Assert // - Validate we received TRUE from AddIngredient Assert.IsTrue(output); }
public bool AddIngredient(Ingredient ingredient) { bool ingredientAdded = false; try { if (ValidateIngredientadd(ingredient)) { IngredientDAL ingredientDAL = new IngredientDAL(); ingredientAdded = ingredientDAL.InsertIngredients(ingredient); } } catch (RecipeIngredientSystemExceptions) { throw; //MessageBox.Show("Do not leave any field blank."); } catch (Exception ex) { throw ex; } return(ingredientAdded); }
public string Insert(Ingredient user) { IngredientDAL userdal = new IngredientDAL(); return(userdal.Insertar(user)); }
public Ingredient GetIngredient(long idproduct, long Idrecipe) { IngredientDAL userdal = new IngredientDAL(); return(userdal.GetIngredient(idproduct, Idrecipe)); }
public Ingredient GetIngredient(long ID) { IngredientDAL userdal = new IngredientDAL(); return(userdal.GetIngredient(ID)); }
public List <Ingredient> GetAll() { IngredientDAL userdal = new IngredientDAL(); return(userdal.GettAll()); }