Esempio n. 1
0
        //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 }));
        }
Esempio n. 2
0
        public void RoundLowerTest()
        {
            var yieldTest = new YieldCalculations();
            var actual    = yieldTest.RoundToInteger(5.56m);
            var expected  = 6;

            Assert.AreEqual(expected, actual);
        }