Example #1
0
        public string Delete(long idproduct, long Idrecipe)
        {
            IngredientDAL userdal = new IngredientDAL();


            return(userdal.Delete(idproduct, Idrecipe));
        }
Example #2
0
        public List <Ingredient> GetByRecipe(long Idrecipe)
        {
            IngredientDAL userdal = new IngredientDAL();


            return(userdal.GetByRecipe(Idrecipe));
        }
Example #3
0
        public string Modify(Ingredient user)
        {
            IngredientDAL userdal = new IngredientDAL();


            return(userdal.Update(user));
        }
Example #4
0
        public List <Ingredient> ExtractAllFromRecipe(long IDRecipe)
        {
            IngredientDAL userdal = new IngredientDAL();


            return(userdal.GetAllFromRecipe(IDRecipe));
        }
Example #5
0
        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);
        }
Example #6
0
        public List <Ingredient> GetIngredient()
        {
            IngredientDAL     ingredientDAL = new IngredientDAL();
            List <Ingredient> ingredients   = ingredientDAL.GetIngredients();

            return(ingredients);
        }
Example #7
0
        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();
        }
Example #8
0
        public string Delete(long ID)
        {
            IngredientDAL userdal = new IngredientDAL();


            return(userdal.Delete(ID));
        }
Example #9
0
        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();
        }
Example #10
0
        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);
        }
Example #11
0
        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);
        }
Example #12
0
        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);
        }
Example #13
0
        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);
        }
Example #14
0
        public string Insert(Ingredient user)
        {
            IngredientDAL userdal = new IngredientDAL();

            return(userdal.Insertar(user));
        }
Example #15
0
        public Ingredient GetIngredient(long idproduct, long Idrecipe)
        {
            IngredientDAL userdal = new IngredientDAL();

            return(userdal.GetIngredient(idproduct, Idrecipe));
        }
Example #16
0
        public Ingredient GetIngredient(long ID)
        {
            IngredientDAL userdal = new IngredientDAL();

            return(userdal.GetIngredient(ID));
        }
Example #17
0
        public List <Ingredient> GetAll()
        {
            IngredientDAL userdal = new IngredientDAL();

            return(userdal.GettAll());
        }