public void TestGetDensityTableInformationFromDensityTable()
        {
            var t             = new DatabaseAccess();
            var dbD           = new DatabaseAccessDensities();
            var dbDI          = new DatabaseAccessDensityInformation();
            var chocolateCake = new Recipe("Chocolate Cake")
            {
                id = 1, yield = 20
            };
            var cakeFlour = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 1, recipeId = 1, sellingWeight = "32 oz", classification = "flour", typeOfIngredient = "cake flour", measurement = "2 cups 2 tablespoons", density = 4.5m, pricePerOunce = .0931m
            };

            t.initializeDatabase();
            dbDI.insertDensityTextFileIntoDensityInfoDatabase();
            dbD.insertIngredientDensityData(cakeFlour);
            var myIngrededientTableInformation = dbD.queryIngredientFromDensityTableByName(cakeFlour);

            Assert.AreEqual(1, myIngrededientTableInformation.ingredientId);
            Assert.AreEqual("32 oz", myIngrededientTableInformation.sellingWeight);
            Assert.AreEqual(32m, myIngrededientTableInformation.sellingWeightInOunces);
            Assert.AreEqual(2.98m, myIngrededientTableInformation.sellingPrice);
            Assert.AreEqual(4.5m, myIngrededientTableInformation.density);
            Assert.AreEqual(.0931m, myIngrededientTableInformation.pricePerOunce);
        }
        public ActionResult DensityInformationTable()
        {
            var dbD = new DatabaseAccessDensityInformation();

            ViewBag.densitytable = dbD.queryDensityInfoTable();
            return(View());
        }
Ejemplo n.º 3
0
        public void TestIngredientTypeGetDensity2()
        {
            var t          = new DatabaseAccessRecipe();
            var dbD        = new DatabaseAccessDensityInformation();
            var breadFlour = new Ingredient("Pillsbury Bread Flour")
            {
                ingredientId = 1, typeOfIngredient = "bread flour"
            };
            var expected = 5.4m;
            var actual   = dbD.queryDensityTableRowDensityValueByName(breadFlour);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void TestIngredientTypeGetDensity()
        {
            var t         = new DatabaseAccessRecipe();
            var dbD       = new DatabaseAccessDensityInformation();
            var cakeFlour = new Ingredient("Softasilk")
            {
                ingredientId = 1, typeOfIngredient = "cake flour"
            };
            var expected = 4.5m;
            var actual   = dbD.queryDensityTableRowDensityValueByName(cakeFlour);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void TestQueryDensityTableDensityByName2()
        {
            var db   = new DatabaseAccess();
            var dbDI = new DatabaseAccessDensityInformation();
            var softasilkCakeFlour = new Ingredient("Softasilk Cake Flour")
            {
                typeOfIngredient = "cake flour"
            };

            db.initializeDatabase();
            dbDI.insertDensityTextFileIntoDensityInfoDatabase();
            var myIngredientDensityInfo = dbDI.queryDensityTableRowDensityValueByName(softasilkCakeFlour);

            Assert.AreEqual(4.5m, myIngredientDensityInfo);
        }
Ejemplo n.º 6
0
        public void TestQueryDensityTableDensityByName()
        {
            var db    = new DatabaseAccess();
            var dbDI  = new DatabaseAccessDensityInformation();
            var flour = new Ingredient("All Purpose Flour")
            {
                density = 5m
            };

            db.initializeDatabase();
            dbDI.insertDensityTextFileIntoDensityInfoDatabase();
            var myIngredientDensityInfo = dbDI.queryDensityTableRowDensityValueByName(flour);

            Assert.AreEqual(5m, myIngredientDensityInfo);
        }
Ejemplo n.º 7
0
        public void TestInsertFileIntoDensityDatabase()
        {
            var t    = new DatabaseAccess();
            var dbDI = new DatabaseAccessDensityInformation();
            var read = new Reader();

            t.initializeDatabase();
            dbDI.insertDensityTextFileIntoDensityInfoDatabase();
            var myDensityInformationIngredients = dbDI.queryDensityInfoTable();

            Assert.AreEqual(41, myDensityInformationIngredients.Count());
            Assert.AreEqual("all purpose flour", myDensityInformationIngredients[0].name);
            Assert.AreEqual(5m, myDensityInformationIngredients[0].density);
            Assert.AreEqual("bananas, mashed", myDensityInformationIngredients[39].name);
            Assert.AreEqual(12m, myDensityInformationIngredients[39].density);
        }
Ejemplo n.º 8
0
        public void TestGetListOfIngredientTypes()
        {
            var t   = new DatabaseAccess();
            var dbD = new DatabaseAccessDensityInformation();

            t.initializeDatabase();
            var firstType  = "all purpose flour";
            var secondType = "bread flour";
            var thirdType  = "cake flour";
            var lastType   = "egg yolk";
            var actual     = dbD.getListOfIngredientTypesFromDensityTable();

            Assert.AreEqual(47, actual.Count());
            Assert.AreEqual(firstType, actual[0]);
            Assert.AreEqual(secondType, actual[1]);
            Assert.AreEqual(thirdType, actual[2]);
            Assert.AreEqual(lastType, actual[46]);
        }
Ejemplo n.º 9
0
        public void TestUpdateDensityInfoTable()
        {
            var t   = new DatabaseAccess();
            var dbD = new DatabaseAccessDensityInformation();
            var i   = new Ingredient("all purpose flour");

            t.initializeDatabase();
            dbD.insertIngredientIntoDensityInfoDatabase(i);
            var BeforeDensityTableInfo = dbD.queryDensityInfoTable();

            i.density = 5m;
            dbD.updateDensityInfoTable(i);
            var AfterDensityTableInfo = dbD.queryDensityInfoTable();

            Assert.AreEqual(1, BeforeDensityTableInfo.Count());
            Assert.AreEqual(1, AfterDensityTableInfo.Count());
            Assert.AreEqual(0, BeforeDensityTableInfo[0].density);
            Assert.AreEqual(5m, AfterDensityTableInfo[0].density);
        }
Ejemplo n.º 10
0
        public void TestReturnDensityFromDensityTable2()
        {
            var t   = new DatabaseAccess();
            var dbD = new DatabaseAccessDensityInformation();
            var r   = new Recipe("bread")
            {
                id = 1
            };
            var i = new Ingredient("Salt")
            {
                recipeId = 1, ingredientId = 1, measurement = "1/2 teaspoon", sellingWeight = "48 oz"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(i, r);
            var expected = 10.72m;
            var actual   = dbD.queryDensityTableRowDensityValueByName(i);

            Assert.AreEqual(expected, actual);
        }
        public void TestQueryCostTableRowByName()
        {
            var db      = new DatabaseAccess();
            var dbI     = new DatabaseAccessIngredient();
            var dbC     = new DatabaseAccessConsumption();
            var dbDI    = new DatabaseAccessDensityInformation();
            var dbD     = new DatabaseAccessDensities();
            var dbCosts = new DatabaseAccessCosts();
            var cake    = new Recipe("Cake")
            {
                id = 1, yield = 12
            };
            var softasilkCakeFlour = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 1, recipeId = 1, sellingWeight = "32 oz", measurement = "1 1/2 cups", typeOfIngredient = "cake flour", classification = "flour"
            };

            db.initializeDatabase();
            dbDI.insertDensityTextFileIntoDensityInfoDatabase();
            dbDI.queryDensityInfoTable();
            dbI.insertIngredient(softasilkCakeFlour, cake);
            var myIngredientInformation = dbI.queryIngredientFromIngredientsTableByName(softasilkCakeFlour);

            dbD.insertIngredientDensityData(softasilkCakeFlour);
            var myIngredientDensityInformation = dbD.queryIngredientFromDensityTableByName(softasilkCakeFlour);

            dbC.insertIngredientConsumtionData(softasilkCakeFlour);
            var myIngredientConsumptionInformation = dbC.queryConsumptionTableRowByName(softasilkCakeFlour);

            //i'm getting 0 for ounces remaining still... i need to figure that one out
            dbCosts.insertIngredientCostDataCostTable(softasilkCakeFlour);
            var myCostIngredientInformation = dbCosts.queryCostsTableByName(softasilkCakeFlour);

            Assert.AreEqual("Softasilk Cake Flour", myCostIngredientInformation.name);
            Assert.AreEqual(2.98m, myCostIngredientInformation.sellingPrice);
            Assert.AreEqual(.0931m, myCostIngredientInformation.pricePerOunce);
            Assert.AreEqual("32 oz", myCostIngredientInformation.sellingWeight);
        }
        public void TestReturnDensityFromDensityTable()
        {
            var t   = new DatabaseAccess();
            var dbD = new DatabaseAccessDensityInformation();
            var r   = new Recipe("bread")
            {
                id = 1
            };
            var i = new Ingredient("all purpose flour")
            {
                recipeId      = 1,
                ingredientId  = 1,
                density       = 5m,
                measurement   = "6 cups",
                sellingWeight = "5 lb"
            };

            t.initializeDatabase();
            t.insertIngredientIntoAllTables(i, r);
            var expected = 5m;
            var actual   = dbD.queryDensityTableRowDensityValueByName(i);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 13
0
        public void TestMultipleIngredientsWithTheSameName()
        {
            var t             = new DatabaseAccess();
            var dbD           = new DatabaseAccessDensityInformation();
            var chocolateCake = new Recipe("Chocolate Cake")
            {
                id = 1, yield = 24
            };
            var yellowCake = new Recipe("Yellow Cake")
            {
                id = 2, yield = 16
            };
            var strawberryShortcake = new Recipe("Strawberry Shortcake")
            {
                id = 3, yield = 8
            };
            var softasilkFlour1 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 1, recipeId = 1, measurement = "1 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour2 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 2, recipeId = 1, measurement = "2 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour3 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 3, recipeId = 1, measurement = "3 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour4 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 4, recipeId = 2, measurement = "1/2 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour5 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 5, recipeId = 2, measurement = "1 1/2 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour6 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 6, recipeId = 2, measurement = "2 1/2 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour7 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 7, recipeId = 3, measurement = "2 1/4 cup", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour8 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 8, recipeId = 3, measurement = "1 tablespoon", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var softasilkFlour9 = new Ingredient("Softasilk Cake Flour")
            {
                ingredientId = 9, recipeId = 3, measurement = "1 tablespoon 2 teaspoons", typeOfIngredient = "cake flour", sellingWeight = "32 oz"
            };
            var chocolateCakeIngredients = new List <Ingredient> {
                softasilkFlour1, softasilkFlour2, softasilkFlour3
            };
            var yellowCakeIngredients = new List <Ingredient> {
                softasilkFlour4, softasilkFlour5, softasilkFlour6
            };
            var strawberryShortcakeIngredients = new List <Ingredient> {
                softasilkFlour7, softasilkFlour8, softasilkFlour9
            };
            var myRecipes = new List <Recipe> {
                chocolateCake, yellowCake, strawberryShortcake
            };
            var myIngredients = new List <Ingredient> {
                softasilkFlour1, softasilkFlour2, softasilkFlour3, softasilkFlour4, softasilkFlour5, softasilkFlour6, softasilkFlour7, softasilkFlour8, softasilkFlour9
            };

            t.initializeDatabase();
            t.insertListOfIngredientsIntoAllTables(chocolateCakeIngredients, chocolateCake);
            t.insertListOfIngredientsIntoAllTables(yellowCakeIngredients, yellowCake);
            t.insertListOfIngredientsIntoAllTables(strawberryShortcakeIngredients, strawberryShortcake);
            var myIngredientBoxDensities = dbD.queryDensityInfoTable();
            var myIngredientBox          = t.queryAllTablesForAllIngredients(myIngredients);

            Assert.AreEqual(4.5m, myIngredientBox[0].density);
            Assert.AreEqual(4.5m, myIngredientBox[1].density);
            Assert.AreEqual(4.5m, myIngredientBox[2].density);
            Assert.AreEqual(4.5m, myIngredientBox[3].density);
            Assert.AreEqual(4.5m, myIngredientBox[4].density);
            Assert.AreEqual(4.5m, myIngredientBox[5].density);
            Assert.AreEqual(4.5m, myIngredientBox[6].density);
            Assert.AreEqual(4.5m, myIngredientBox[7].density);
            Assert.AreEqual(4.5m, myIngredientBox[8].density);
            Assert.AreEqual(.42m, myIngredientBox[0].priceOfMeasuredConsumption);
            Assert.AreEqual(.84m, myIngredientBox[1].priceOfMeasuredConsumption);
            Assert.AreEqual(1.26m, myIngredientBox[2].priceOfMeasuredConsumption);
            Assert.AreEqual(.21m, myIngredientBox[3].priceOfMeasuredConsumption);
            Assert.AreEqual(.63m, myIngredientBox[4].priceOfMeasuredConsumption);
            Assert.AreEqual(1.05m, myIngredientBox[5].priceOfMeasuredConsumption);
            Assert.AreEqual(.94m, myIngredientBox[6].priceOfMeasuredConsumption);
            Assert.AreEqual(.03m, myIngredientBox[7].priceOfMeasuredConsumption);
            Assert.AreEqual(.04m, myIngredientBox[8].priceOfMeasuredConsumption);
        }
        public ActionResult Recipe(string name)
        {
            var rest = new MakeRESTCalls();
            var db   = new DatabaseAccess();
            var dbI  = new DatabaseAccessIngredient();
            var dbD  = new DatabaseAccessDensityInformation();
            var dbC  = new DatabaseAccessConsumption();

            if (string.IsNullOrEmpty(name))
            {
                return(Redirect("/home/RecipeBox"));
            }
            name = name.Trim();
            var distinctIngredientNamesSorted     = dbI.myDistinctIngredientNamesSorted();
            var distinctIngredientClassifications = dbI.myDistinctIngredientClassificationsSorted();
            var distinctIngredientTypes           = dbI.myDistinctIngredientTypesSorted();

            myDatabaseRecipe          = getRecipes().First(x => x.name == name);
            currentRecipe             = myDatabaseRecipe;
            ViewBag.currentingredient = currentIngredient;
            if (distinctIngredientNamesSorted.Count() == 0 || distinctIngredientNamesSorted == null)
            {
                ViewBag.ingredientnames = new List <string>();
            }
            else
            {
                ViewBag.ingredientnames = distinctIngredientNamesSorted;
            }
            if (distinctIngredientTypes.Count() == 0 || distinctIngredientTypes == null)
            {
                ViewBag.types = new List <string>();
            }
            else
            {
                ViewBag.types = distinctIngredientTypes;
            }
            if (distinctIngredientClassifications.Count() == 0 || distinctIngredientClassifications == null)
            {
                ViewBag.classifications = new List <string>();
            }
            else
            {
                ViewBag.classifications = distinctIngredientClassifications;
            }

            ViewBag.distinctsellingweights = dbC.getListOfDistinctSellingWeights();
            ViewBag.currentrecipe          = currentRecipe;
            ViewBag.recipeboxcount         = getRecipes().Count();
            //ViewBag.distinctingredienttypes = dbD.getListOfIngredientTypesFromDensityTable();
            if (!string.IsNullOrEmpty(currentIngredient.name))
            {
                if (string.IsNullOrEmpty(currentIngredient.measurement))
                {
                    ViewBag.itemresponselist = rest.GetListItemResponseNoSellingWeights(currentIngredient);
                }
                else
                {
                    ViewBag.itemresponselist         = rest.GetListItemResponses(currentIngredient);
                    ViewBag.itemresponselistcombined = rest.CombineItemResponses(currentIngredient);
                }
            }
            else
            {
                ViewBag.itemresponselist         = new List <ItemResponse>();
                ViewBag.itemresponselistNoWeight = new List <ItemResponse>();
            }
            return(View());

            /*
             * foreach of these item responses in the list of item responses i think it would be wise to have an
             * algorithm to filter out the top 2 prices (or put them at the end of the list and gray them out so they're visible but not prominent...
             * there's a product of 6 5 lb bags of king arthur organic unbleached flour, but in the itemr esponse name, it doesn't give any specification of packs in it's name, so my algorithm wouldn't be able to do anything with it
             * unless i took the largest price and divided it by the average of the other prices and compared them, seeing if it was a pack that way...
             */
        }