//update the recipe yield public ActionResult UpdateRecipeYield(int RecipeIdInput, string YieldMultiplierInput) { RecipeIdInputStatic = RecipeIdInput; var db = new BakeryInventoryEntities(); var rec = db.Recipe; var recToUpdate = (from r in rec where r.RecipeId == RecipeIdInput select r).First(); var yieldAdjustmentCalculations = new YieldCalculations(); var yieldMultiplier = 0m; if (YieldMultiplierInput.Contains('/')) //if the value is a fraction, then convert it to a rounded decimal { var parseFractionToDecimal = new ParseFractionToDecimal(); yieldMultiplier = parseFractionToDecimal.CalculateFractionToDecimal(YieldMultiplierInput); } else { yieldMultiplier = System.Convert.ToDecimal(YieldMultiplierInput); } if (recToUpdate.Yield == 0) { recToUpdate.Yield = yieldAdjustmentCalculations.RoundToInteger(yieldMultiplier); } recToUpdate.Yield = yieldAdjustmentCalculations.RoundToInteger(recToUpdate.Yield * yieldMultiplier); db.SaveChanges(); return(RedirectToAction("RecipeIngredients", new { RecipeIdInput = RecipeIdInputStatic })); }
//InsertMethods public ActionResult InsertIngredient(int RecipeIdInput, string NameInput, string WeightValueInput, int WeightIdInput, string MeasurementValueInput, int MeasurementTypeIdInput, int IngredientTypeIdInput) { var db = new BakeryInventoryEntities(); var rec = db.Recipe; ViewBag.AllRecipes = (from r in rec select r).ToList(); var intTypes = db.IngredientType; ViewBag.AllIngredientTypes = (from it in intTypes select it).ToList(); var measTypes = db.MeasurementType; ViewBag.AllMeasurementTypes = (from mt in measTypes select mt).ToList(); var wType = db.Weight; ViewBag.AllWeights = (from w in wType select w).ToList(); var ingDets = db.vw_IngredientDetails; ViewBag.AllIngredientDetails = (from id in ingDets select id).ToList(); var ing = db.Ingredient; var ins = new Ingredient { Name = NameInput, RecipeId = RecipeIdInput, WeightValue = System.Convert.ToDecimal(WeightValueInput), WeightId = WeightIdInput, MeasurementValue = System.Convert.ToDecimal(MeasurementValueInput), MeasurementTypeId = MeasurementTypeIdInput, IngredientTypeId = IngredientTypeIdInput }; db.Ingredient.Add(ins); db.SaveChanges(); return(View("Ingredient")); }
//InsertMethods public ActionResult InsertRecipe(string RecipeNameInput, int YieldInput, int RecipeTypeIdInput) { var db = new BakeryInventoryEntities(); var rec = db.Recipe; var ins = new Recipe { Name = RecipeNameInput, Yield = YieldInput, RecipeTypeId = RecipeTypeIdInput }; db.Recipe.Add(ins); db.SaveChanges(); return(RedirectToAction("Recipe")); }
public ActionResult InsertIngredientForRecipe(int RecipeIdInputIns, string NameInput, string MeasurementValueInput, int MeasurementTypeIdInput, int IngredientTypeIdInput) { var db = new BakeryInventoryEntities(); var ing = db.Ingredient; RecipeIdInputStatic = RecipeIdInputIns; var ins = new Ingredient { Name = NameInput, RecipeId = RecipeIdInputIns, MeasurementValue = System.Convert.ToDecimal(MeasurementValueInput), MeasurementTypeId = MeasurementTypeIdInput, //hardcoded temporarily IngredientTypeId = IngredientTypeIdInput //harcoded temporarily }; db.Ingredient.Add(ins); db.SaveChanges(); return(RedirectToAction("RecipeIngredients", new { RecipeIdInput = RecipeIdInputStatic })); }