//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 })); }
public void ParseProperFractionToDecimal2() { var parse = new ParseFractionToDecimal(); var actual = parse.CalculateFractionToDecimal("3 4/5"); var expected = 3.8m; Assert.AreEqual(expected, actual); }
public void ParseComplexPractionToDecimal2() { var parse = new ParseFractionToDecimal(); var actual = parse.CalculateFractionToDecimal("126/14"); var expected = 9m; Assert.AreEqual(expected, actual); }
public void ParseComplexFractionToDecimal() { var parse = new ParseFractionToDecimal(); var actual = parse.CalculateFractionToDecimal("45/89"); var expected = .50m; Assert.AreEqual(expected, actual); }
public void ParseSimpleFractionToDecimal() { var parse = new ParseFractionToDecimal(); var actual = parse.CalculateFractionToDecimal("1/2"); var expected = .5m; Assert.AreEqual(expected, actual); }