public IBU CalculateIBU(Recipe recipe) { var og = recipe.OG; var ibu = new IBU { IbuId = recipe.RecipeId }; var tinseth = 0.0; var rager = 0.0; foreach (var boilStep in recipe.BoilSteps) { var tinsethUtilisation = Formulas.TinsethUtilisation(og, boilStep.Length); var ragerUtilisation = Formulas.RangerUtilisation(boilStep.Length); foreach (var hop in boilStep.Hops) { var tinasethMgl = Formulas.TinsethMgl(hop.Amount, hop.AAValue, recipe.Volume); tinseth += Formulas.TinsethIbu(tinasethMgl, tinsethUtilisation); rager += Formulas.RangerIbu(hop.Amount, ragerUtilisation, hop.AAValue, recipe.Volume, og); } } ibu.Tinseth = Math.Round(tinseth, 1); ibu.Standard = Math.Round(tinseth, 1); ibu.Rager = Math.Round(rager, 1); return(ibu); }
public IBUDto CalculateIBUDto(RecipeDto recipe) { var og = recipe.OG; var ibu = new IBUDto(); var tinseth = 0.0; var rager = 0.0; foreach (var item in recipe.Steps.OfType <BoilStepDto>()) { var boilStep = (BoilStepDto)item; var tinsethUtilisation = Formulas.TinsethUtilisation(og, boilStep.Length); var ragerUtilisation = Formulas.RangerUtilisation(boilStep.Length); foreach (var hop in boilStep.Ingredients.OfType <HopStepDto>()) { var tinasethMgl = Formulas.TinsethMgl(hop.Amount, hop.AAValue, recipe.Volume); tinseth += Formulas.TinsethIbu(tinasethMgl, tinsethUtilisation); rager += Formulas.RangerIbu(hop.Amount, ragerUtilisation, hop.AAValue, recipe.Volume, og); } } ibu.Tinseth = Math.Round(tinseth, 1); ibu.Standard = Math.Round(tinseth, 1); ibu.Rager = Math.Round(rager, 1); return(ibu); }