public List <ItemResponse> GetListItemResponses(Ingredient i) { var db = new DatabaseAccessRecipe(); var convert = new ConvertWeight(); var items = MakeRequest <SearchResponse>(buildSearchRequest(i)).Items; var sellingWeightOunces = convert.ConvertWeightToOunces(i.sellingWeight); var myListOfItemResponses = new List <ItemResponse>(); foreach (var item in items) { if (!item.name.Contains('(')) { if ((!item.name.ToLower().Contains("pack of")) || (!item.name.ToLower().Contains(("pk")))) { if ((parseItemResponseName(item).Count() != 0) && (CompareWeightInOuncesFromItemResponseToIngredientSellingWeight(item, i) && (CompareItemResponseNameAndIngredientName(item, i)))) { myListOfItemResponses.Add(item); } } } } return(myListOfItemResponses); //i would like to be able to return all brands that fit a certain selling weight, and give all of them as an option, and give the best price? //i think a good idea would be to have the item id associated with the ingredient in the ingredient database or the cost database, that way you can get the exact same item }
public void TestDeleteIngredientFromCostTable() { var t = new DatabaseAccess(); var dbC = new DatabaseAccessCosts(); var dbR = new DatabaseAccessRecipe(); var bread = new Recipe("Bread") { id = 1 }; var honey = new Ingredient("Honey") { ingredientId = 1, recipeId = 1, typeOfIngredient = "honey", measurement = "1/3 cup", sellingWeight = "32 oz" }; t.initializeDatabase(); t.insertIngredientIntoAllTables(honey, bread); var myRecipes = dbR.MyRecipeBox(); var myIngredients = t.queryAllRelevantTablesSQLByIngredientName(honey); dbC.DeleteIngredientFromCostTable(honey); var myCostIngredients = dbC.queryCostTable(); Assert.AreEqual(1, myRecipes.Count()); Assert.AreEqual(1, myRecipes[0].ingredients.Count()); Assert.AreEqual(0, myCostIngredients.Count()); }
public void TestOverwritingTheCostTable() { var t = new DatabaseAccess(); var dbC = new DatabaseAccessCosts(); var dbR = new DatabaseAccessRecipe(); var yellowCake = new Recipe("Yellow Cake") { id = 1, yield = 12 }; var milk = new Ingredient("Whole Milk") { ingredientId = 1, recipeId = 1, measurement = "1 cup", sellingWeight = "1 gallon", typeOfIngredient = "milk", classification = "dairy" }; t.initializeDatabase(); t.insertIngredientIntoAllTables(milk, yellowCake); var myIngredient = t.queryAllRelevantTablesSQLByIngredientName(milk); milk.sellingPrice = 2.98m; dbC.updateCostDataTable(milk); var myCostIngredient = dbC.queryCostTable(); t.updateAllTables(milk, yellowCake); var myUpdatedIngredient = t.queryAllRelevantTablesSQLByIngredientName(milk); var myRecipeBox = dbR.MyRecipeBox(); Assert.AreEqual(1, myRecipeBox[0].ingredients.Count()); Assert.AreEqual(2.98m, myUpdatedIngredient.sellingPrice); Assert.AreEqual(8.2m, myIngredient.density); Assert.AreEqual(.19m, myUpdatedIngredient.priceOfMeasuredConsumption); Assert.AreEqual(.0233m, myUpdatedIngredient.pricePerOunce); }
public void TestHersheysUnsweetenedCocoa() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var r = new Recipe("Chocolate Something") { id = 1 }; var i = new Ingredient("Hershey's Special Dark Cocoa") { recipeId = 1, ingredientId = 1, sellingWeight = "8 oz", measurement = "1/2 cup", density = 4.16m }; t.initializeDatabase(); dbR.InsertRecipe(r); t.insertIngredientIntoAllTables(i, r); dbI.getIngredientMeasuredPrice(i, r); var myIngInfo = dbI.queryAllIngredientsFromIngredientTable(); var myRecipesInfo = dbR.queryRecipes(); Assert.AreEqual(1, myRecipesInfo.Count()); Assert.AreEqual(.87m, myIngInfo[0].priceOfMeasuredConsumption); }
public void TestOverwritingTheCostTable3() { var t = new DatabaseAccess(); var dbC = new DatabaseAccessCosts(); var dbR = new DatabaseAccessRecipe(); var chocolateCake = new Recipe("Chocolate Cake") { id = 1, yield = 16 }; var softasilk = new Ingredient("Softasilk Flour") { recipeId = 1, ingredientId = 1, sellingWeight = "32 oz", measurement = "3 cups", typeOfIngredient = "cake flour", classification = "flour" }; t.initializeDatabase(); t.insertIngredientIntoAllTables(softasilk, chocolateCake); var myIngredient = t.queryAllRelevantTablesSQLByIngredientName(softasilk); softasilk.sellingPrice = 5m; var costTable = dbC.queryCostTable(); t.updateAllTables(softasilk, chocolateCake); var myUpdatedIngredient = t.queryAllRelevantTablesSQLByIngredientName(softasilk); var myRecipeBox = dbR.MyRecipeBox(); Assert.AreEqual(1.26m, myIngredient.priceOfMeasuredConsumption); Assert.AreEqual(2.11m, myUpdatedIngredient.priceOfMeasuredConsumption); Assert.AreEqual(2.11m, myRecipeBox[0].aggregatedPrice); }
public void TestChocolateChips() { var dbD = new DatabaseAccessDensityInformation(); var dbR = new DatabaseAccessRecipe(); var t = new DatabaseAccess(); var r = new Recipe("Chooalte Chip Cookies") { id = 1 }; var i = new Ingredient("Semi Sweet Morsels") { ingredientId = 1, recipeId = 1, sellingWeight = "36 oz", density = 5.35m, measurement = "1 cup" }; //6.98 1.04 t.initializeDatabase(); //var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRosesWebPages\RachelsRosesWebPages\densityTxtDatabase.txt"; dbD.insertDensityTextFileIntoDensityInfoDatabase(); t.insertIngredientIntoAllTables(i, r); var mydensityDataInformation = dbD.queryDensityInfoTable(); var semiSweetMorsels = t.queryAllRelevantTablesSQLByIngredientName(i); var myRecipes = dbR.MyRecipeBox(); Assert.AreEqual("all purpose flour", mydensityDataInformation[0].name); Assert.AreEqual(1, myRecipes.Count()); Assert.AreEqual(6.98m, semiSweetMorsels.sellingPrice); Assert.AreEqual(6.98m, myRecipes[0].ingredients[0].sellingPrice); Assert.AreEqual(1.04m, semiSweetMorsels.priceOfMeasuredConsumption); Assert.AreEqual(1.04m, myRecipes[0].ingredients[0].priceOfMeasuredConsumption); }
public void TestInsertIngredientToIngredientDatabase() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var r = new Recipe("Cranberry Swirl Bread") { id = 1 }; var i = new Ingredient("Cranberries", "2 cups") { recipeId = r.id }; t.initializeDatabase(); dbR.InsertRecipe(r); dbI.insertIngredient(i, r); var myRecipeBox = dbR.queryRecipes(); var myIngredientBox = dbI.queryAllIngredientsFromIngredientTable(); var myRecipe = dbR.GetFullRecipeAndFullIngredientsForRecipe(r); Assert.AreEqual(r.name, myRecipeBox[0].name); Assert.AreEqual(i.name, myIngredientBox[0].name); Assert.AreEqual(i.measurement, myIngredientBox[0].measurement); Assert.AreEqual(i.name, myRecipe.ingredients[0].name); Assert.AreEqual(i.measurement, myRecipe.ingredients[0].measurement); }
public void TestIngredientTable() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var i = new Ingredient("all-purpose flour", "2 1/2 cups") { recipeId = 1 }; var i2 = new Ingredient("butter", "1/2 cup") { recipeId = 1 }; var r = new Recipe("White Cake") { id = 1 }; t.initializeDatabase(); dbR.InsertRecipe(r); dbI.insertIngredient(i, r); dbI.insertIngredient(i2, r); var recipes = dbR.queryRecipes(); var ingredients = dbI.queryAllIngredientsFromIngredientTable(); var myIngredientBox = dbI.queryAllIngredientsFromIngredientTable(); Assert.AreEqual("all-purpose flour", ingredients[0].name); Assert.AreEqual("butter", ingredients[1].name); }
public void TestUpdatingIngredients() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var r = new Recipe("Honey Buttermilk Bread"); var i = new Ingredient("Flour", "6 cups") { recipeId = 1, ingredientId = 1 }; var i2 = new Ingredient("Bread Flour", "6 1/3 cups") { recipeId = 1, ingredientId = 1 }; i = i2; t.initializeDatabase(); dbR.InsertRecipe(r); dbI.insertIngredient(i, r); dbI.UpdateIngredient(i); var myIngredientBox = dbI.queryAllIngredientsFromIngredientTable(); Assert.AreEqual(i2.name, myIngredientBox[0].name); Assert.AreEqual(i2.measurement, myIngredientBox[0].measurement); }
public void TestGettingUniqueEntriesINIngredientTable() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var fluffyWhiteCake = new Recipe("Fluffy White Cake") { id = 1, yield = 12 }; var chocolateCake = new Recipe("My Favorite Chocolat Cake") { id = 2, yield = 18 }; var yellowCake = new Recipe("Yellow Cake") { id = 3, yield = 16 }; var softasilk = new Ingredient("Softasilk Cake Flour") { ingredientId = 1, recipeId = 1, measurement = "2 cups 2 tablespoons", typeOfIngredient = "cake flour", sellingWeight = "32 oz" }; var softasilk2 = new Ingredient("Softasilk Cake Flour") { ingredientId = 2, recipeId = 2, measurement = "3 cups", typeOfIngredient = "cake flour", sellingWeight = "32 oz" }; var softasilk3 = new Ingredient("Softasilk Cake Flour") { ingredientId = 3, recipeId = 3, measurement = "1 1/2 cups", typeOfIngredient = "cake flour", sellingWeight = "32 oz" }; var bakingPowder = new Ingredient("Baking Powder") { ingredientId = 4, recipeId = 3, measurement = "2 teaspoons", typeOfIngredient = "baking powder", sellingWeight = "10 oz" }; var yellowCakeIngredients = new List <Ingredient> { softasilk3, bakingPowder }; var myIngredientBox = new List <Ingredient> { softasilk, softasilk2, softasilk3, bakingPowder }; t.initializeDatabase(); t.insertIngredientIntoAllTables(softasilk, fluffyWhiteCake); t.insertIngredientIntoAllTables(softasilk2, chocolateCake); t.insertListOfIngredientsIntoAllTables(yellowCakeIngredients, yellowCake); var myIngredientsTable = dbI.queryAllIngredientsFromIngredientTable(); var myRecipeBox = dbR.MyRecipeBox(); var myDistictIngredientTable = dbI.myDistinctIngredientNamesSorted(); var myIngredientBoxFilled = t.queryAllTablesForAllIngredients(myIngredientBox); Assert.AreEqual(4, myIngredientsTable.Count()); Assert.AreEqual(2, myDistictIngredientTable.Count()); Assert.AreEqual("Softasilk Cake Flour", myDistictIngredientTable[0]); Assert.AreEqual("Baking Powder", myDistictIngredientTable[1]); Assert.AreEqual(.89m, softasilk.priceOfMeasuredConsumption); Assert.AreEqual(1.26m, softasilk2.priceOfMeasuredConsumption); Assert.AreEqual(.63m, softasilk3.priceOfMeasuredConsumption); Assert.AreEqual(.10m, bakingPowder.priceOfMeasuredConsumption); }
//so, if we're searching for something, it's not in our database... //it may share a type, but it's not in the database... //so when i search for it, i can give the user what i think the name, the selling weigh, the selling price, type and classificatoin (i could provide a list of classifications too, similar to my density text database... //so, first give a list of the name, sellingweight, sellingprice, priceperounce, type, density, classification... //if the user confirms that the information is correct and gives the measurement, then i can add the ingredient (i should be able to call updatealltables... it should check to make sure i have if the ingredients table doesn't have this ingredient to insert the ingredient //i should also have a form that allows hte user to create a short name for it (eg: instead of King Arthur Bread Flour, the short name can be Bread Flour that the user inputs...) //let's get the other views working first... public ActionResult CreateRecipe(string recipeTitle) { recipeTitle = recipeTitle.Trim(); Recipe newrecipe = new Recipe(recipeTitle); var db = new DatabaseAccessRecipe(); db.InsertRecipe(newrecipe); return(Redirect("/home/RecipeBox")); }
protected void Application_Start() { var db = new DatabaseAccessRecipe(); //db.initializeDatabase(); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public ActionResult EditRecipeTitle(string newRecipeTitle) { var db = new DatabaseAccessRecipe(); currentRecipe.name = newRecipeTitle; db.UpdateRecipe(currentRecipe); var myRecipeBox = getRecipes(); return(Redirect("/home/recipe?name=" + newRecipeTitle)); }
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); }
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); }
public ActionResult DeleteRecipe(string recipeTitle) { recipeTitle = recipeTitle.Trim(); var db = new DatabaseAccessRecipe(); var recipes = db.queryRecipes(); foreach (var recipe in recipes) { if (recipe.name == recipeTitle) { currentRecipe = recipe; } db.DeleteRecipeAndRecipeIngredients(currentRecipe); } return(Redirect("/home/RecipeBox")); }
public List <ItemResponse> GetListItemResponseNoSellingWeights(Ingredient i) { var db = new DatabaseAccessRecipe(); //var convert = new ConvertWeight(); var items = MakeRequest <SearchResponse>(buildSearchRequest(i)).Items; var myListOfResponses = new List <ItemResponse>(); foreach (var item in items) { if (item.name.Contains(i.name)) { myListOfResponses.Add(item); } } return(myListOfResponses); }
public ActionResult AdjustYield(int updatedYield) { var t = new DatabaseAccessRecipe(); var convert = new ConvertMeasurement(); if (currentRecipe.yield == 0) { currentRecipe.yield = updatedYield; } else { var oldYield = currentRecipe.yield; currentRecipe.yield = updatedYield; t.UpdateRecipeYield(currentRecipe); } t.UpdateRecipe(currentRecipe); return(Redirect("/home/recipe?name=" + currentRecipe.name)); }
public void TestQueryListOfIngredientsDensityCostTableAdded() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var cocnutMacaroons = new Recipe("Coconut Macaroons") { id = 1 }; var i = new Ingredient("Baker's Coconut Flakes") { recipeId = 1, measurement = "1 cup", sellingWeight = "14 oz", density = 2.5m, ingredientId = 1 //2.6, .46 }; var i2 = new Ingredient("All Purpose Flour") { recipeId = 1, measurement = "1/2 cup", sellingWeight = "5 lb", density = 5m, ingredientId = 2 //3.65 }; var cocnutMcaroonsIngredients = new List <Ingredient> { i, i2 }; t.initializeDatabase(); t.insertListOfIngredientsIntoAllTables(cocnutMcaroonsIngredients, cocnutMacaroons); var myIngredients = t.queryAllTablesForAllIngredients(cocnutMcaroonsIngredients); var myRecipes = dbR.queryRecipes(); Assert.AreEqual(1, myRecipes.Count()); Assert.AreEqual(2, myIngredients.Count()); Assert.AreEqual(2.60m, myIngredients[0].sellingPrice); Assert.AreEqual(.46m, myIngredients[0].priceOfMeasuredConsumption); Assert.AreEqual(.1857m, myIngredients[0].pricePerOunce); Assert.AreEqual(2.5m, myIngredients[0].density); Assert.AreEqual(3.65m, myIngredients[1].sellingPrice); Assert.AreEqual(.11m, myIngredients[1].priceOfMeasuredConsumption); Assert.AreEqual(.0456m, myIngredients[1].pricePerOunce); Assert.AreEqual(5m, myIngredients[1].density); }
public ItemResponse GetItemResponse(Ingredient i) { var db = new DatabaseAccessRecipe(); var convert = new ConvertWeight(); var newItemResponse = new ItemResponse(); var tempItemResponse = new ItemResponse(); try { if (string.IsNullOrEmpty(i.classification) || (i.classification == " ") || !(i.classification.ToLower().Contains("dairy")) || !(i.classification.ToLower().Contains("egg"))) { if ((MakeRequest <SearchResponse>(buildSearchRequest(i)).Items.Count() == 0)) { return(newItemResponse);//ok, selling weight is not being transfered } var items = MakeRequest <SearchResponse>(buildSearchRequest(i)).Items; var sellingWeightOunces = convert.ConvertWeightToOunces(i.sellingWeight); foreach (var item in items) { if (!item.name.Contains('(')) { if ((!item.name.ToLower().Contains("pack of")) || (!item.name.ToLower().Contains(("pk")))) { if ((parseItemResponseName(item).Count() != 0) && (CompareWeightInOuncesFromItemResponseToIngredientSellingWeight(item, i) && (CompareItemResponseNameAndIngredientName(item, i)))) { tempItemResponse = item; break; } } } } } else { if ((i.classification.ToLower().Contains("dairy")) || i.classification.ToLower().Contains("eggs")) { return(newItemResponse); } } } catch { return(newItemResponse); } return(tempItemResponse); //i would like to be able to return all brands that fit a certain selling weight, and give all of them as an option, and give the best price? }
public void TestOverwritingTheCostTable2() { var t = new DatabaseAccess(); var dbC = new DatabaseAccessCosts(); var dbR = new DatabaseAccessRecipe(); var chocolateCake = new Recipe("Chocolate Cake") { id = 1, yield = 24 }; var yellowCake = new Recipe("Yellow Cake") { id = 2, yield = 24 }; var honeyButtermilkBread = new Recipe("Honey Buttermilk Bread") { id = 3, yield = 24 }; var sourCream = new Ingredient("Sour Cream") { ingredientId = 1, recipeId = 1, measurement = "1 cup", sellingWeight = "16 oz", typeOfIngredient = "sour cream", classification = "dairy" }; var milk = new Ingredient("Whole Milk") { ingredientId = 2, recipeId = 2, measurement = "1 1/2 cups", sellingWeight = "1 gallon", typeOfIngredient = "milk", classification = "dairy" }; var butter = new Ingredient("Unsalted Butter") { ingredientId = 3, recipeId = 3, measurement = "1/4 cup", sellingWeight = "1 lb", typeOfIngredient = "butter", classification = "dairy" }; var buttermilk = new Ingredient("Buttermilk") { ingredientId = 4, recipeId = 3, measurement = "2 cups", sellingWeight = "1/4 gallon", typeOfIngredient = "buttermilk", classification = "dairy" }; var honeyButtermilkBreadIngredients = new List <Ingredient> { butter, buttermilk }; var allIngredients = new List <Ingredient> { sourCream, milk, butter, buttermilk }; t.initializeDatabase(); t.insertIngredientIntoAllTables(sourCream, chocolateCake); t.insertIngredientIntoAllTables(milk, yellowCake); t.insertListOfIngredientsIntoAllTables(honeyButtermilkBreadIngredients, honeyButtermilkBread); var myIngredients = t.queryAllTablesForAllIngredients(allIngredients); sourCream.sellingPrice = 1.69m; milk.sellingPrice = 2.98m; butter.sellingPrice = 3.99m; buttermilk.sellingPrice = 1.69m; var costTable = dbC.queryCostTable(); t.updateAllTables(sourCream, chocolateCake); t.updateAllTables(milk, yellowCake); t.updateAllTablesForAllIngredients(honeyButtermilkBreadIngredients, honeyButtermilkBread); var myUpdatedIngredients = t.queryAllTablesForAllIngredients(allIngredients); var myRecipeBox = dbR.MyRecipeBox(); Assert.AreEqual(1.69m, myUpdatedIngredients[0].sellingPrice); Assert.AreEqual(2.98m, myUpdatedIngredients[1].sellingPrice); Assert.AreEqual(3.99m, myUpdatedIngredients[2].sellingPrice); Assert.AreEqual(1.69m, myUpdatedIngredients[3].sellingPrice); Assert.AreEqual(8.6m, myUpdatedIngredients[0].density); Assert.AreEqual(8.2m, myUpdatedIngredients[1].density); Assert.AreEqual(8m, myUpdatedIngredients[2].density); Assert.AreEqual(8.2m, myUpdatedIngredients[3].density); Assert.AreEqual(.91m, myUpdatedIngredients[0].priceOfMeasuredConsumption); Assert.AreEqual(.91m, myRecipeBox[0].ingredients[0].priceOfMeasuredConsumption); Assert.AreEqual(.29m, myUpdatedIngredients[1].priceOfMeasuredConsumption); Assert.AreEqual(.29m, myRecipeBox[1].ingredients[0].priceOfMeasuredConsumption); Assert.AreEqual(.5m, myUpdatedIngredients[2].priceOfMeasuredConsumption); Assert.AreEqual(.5m, myRecipeBox[2].ingredients[0].priceOfMeasuredConsumption); Assert.AreEqual(.87m, myUpdatedIngredients[3].priceOfMeasuredConsumption); Assert.AreEqual(.87m, myRecipeBox[2].ingredients[1].priceOfMeasuredConsumption); Assert.AreEqual(.91m, myRecipeBox[0].aggregatedPrice); Assert.AreEqual(.29m, myRecipeBox[1].aggregatedPrice); Assert.AreEqual(1.37m, myRecipeBox[2].aggregatedPrice); }
public List <Recipe> getRecipes() { var db = new DatabaseAccessRecipe(); return(db.MyRecipeBox()); }