예제 #1
0
        public static SRMDto CalculateSRMDto(RecipeDto recipe)
        {
            var srm = new SRMDto { SrmId = recipe.Id };
            foreach (var mashStep in recipe.MashSteps)
            {
                var volume = recipe.Volume;
                if (mashStep.Volume > 0)
                    volume = mashStep.Volume;
                foreach (var fermentable in mashStep.Fermentables.Where(f => f != null))
                {
                    srm.Standard += Math.Round(Formulas.MaltColourUnits(fermentable.Amount, fermentable.Lovibond, volume), 0);
                    srm.Morey += Math.Round(Formulas.Morey(fermentable.Amount, fermentable.Lovibond, volume), 0);
                    srm.Mosher += Math.Round(Formulas.Morey(fermentable.Amount, fermentable.Lovibond, volume), 0);
                    srm.Daniels += Math.Round(Formulas.Daniels(fermentable.Amount, fermentable.Lovibond, volume), 0);
                }
            }

            return srm;
        }
예제 #2
0
        public static IBUDto CalculateIBUDto(RecipeDto recipe)
        {
            var og = recipe.OG;
            var ibu = new IBUDto { IbuId = recipe.Id };

            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 async void AddBeer_Gets_Added()
        {
            var beer = new BeerDto
            {
                Name = "Test Beer",
                BeerStyle = new BeerStyleSimpleDto {Id = 1, Name = "American-Style Wheat Beer"},
                Brewers = new List<DTOUser> { new DTOUser { Username = "******"} },
            };

            var recipe = new RecipeDto
            {
                MashSteps = new List<MashStepDto>{new MashStepDto{StepNumber = 1}},
                //SpargeStep = new List<SpargeStepDto>{new SpargeStepDto{StepNumber = 2,Amount = 1, Temperature = 80}},
                SpargeStep = new SpargeStepDto{StepNumber = 2,Amount = 1, Temperature = 80},
                BoilSteps = new List<BoilStepDto> {new BoilStepDto {StepNumber = 3}},
                FermentationSteps = new List<FermentationStepDto> {new FermentationStepDto{StepNumber = 4}},
                Volume = 20,
                Efficiency = 75,
            };

            beer.Recipe = recipe;
            var beerDto = await _beerService.AddAsync(beer);
            Assert.NotNull(beerDto);
        }
예제 #4
0
        public static ABVDto CalculateABVDto(RecipeDto recipe)
        {
            var abv = new ABVDto
            {
                AbvId = recipe.Id,
                Miller = Math.Round(Formulas.MillerABV(recipe.OG, recipe.FG), 2),
                Simple = Math.Round(Formulas.SimpleABV(recipe.OG, recipe.FG), 2),
                Advanced = Math.Round(Formulas.AdvancedABV(recipe.OG, recipe.FG), 2),
                AdvancedAlternative = Math.Round(Formulas.AdvancedAlternativeABV(recipe.OG, recipe.FG), 2),
                AlternativeSimple = Math.Round(Formulas.SimpleAlternativeABV(recipe.OG, recipe.FG), 2),
                Standard = Math.Round(Formulas.MicrobrewitABV(recipe.OG, recipe.FG), 2)
            };

            return abv;
        }
예제 #5
0
        public static double CalculateOGDto(RecipeDto recipe)
        {
            var og = 0.0;

            try
            {
                foreach (var fermentable in recipe.MashSteps.SelectMany(mashStep => mashStep.Fermentables.Where(f => f != null)))
                {
                    var efficency = recipe.Efficiency;
                    //if (fermentable.PPG <= 0)
                    //{
                    var esFermentable = _fermentableElasticsearch.GetSingle(fermentable.FermentableId);
                    if (esFermentable != null && esFermentable.PPG > 0)
                    {
                        fermentable.PPG = esFermentable.PPG;
                        if (esFermentable.Type.Contains("Extract") || esFermentable.Type.Contains("Sugar"))
                            efficency = 100;
                        //og += Formulas.MaltOG(fermentable.Amount, esFermentable.PPG, recipe.Efficiency, recipe.Volume);
                    }
                    else
                    {
                        var efFermentable = _fermentableRepository.GetSingle(fermentable.FermentableId);
                        if (efFermentable?.PPG != null)
                        {
                            fermentable.PPG = (int) efFermentable.PPG;
                            if (efFermentable.Type.Contains("Extract") || efFermentable.Type.Contains("Sugar"))
                                efficency = 100;
                        }
                        //og += Formulas.MaltOG(fermentable.Amount, (int)efFermentable.PPG, recipe.Efficiency, recipe.Volume);
                    }

                    //}
                    og += Formulas.MaltOG(fermentable.Amount, (int) fermentable.PPG, efficency, recipe.Volume);
                }
            }
            catch (Exception exception)
            {

                throw;
            }

            return Math.Round(1 + og / 1000, 4);
        }