Exemplo n.º 1
0
        private BeerRecipeCore.Styles.Style GetBeerRecipeCoreStyle(Style style)
        {
            var styleForBeerRecipeCore = _mapper.Map <Style, BeerRecipeCore.Styles.Style>(style);

            LoadFermentables(styleForBeerRecipeCore, style.CommonGrains);
            LoadHops(styleForBeerRecipeCore, style.CommonHops);
            styleForBeerRecipeCore.CommonYeast = GetYeast(style.CommonYeastId);
            return(styleForBeerRecipeCore);
        }
Exemplo n.º 2
0
        public void CreateBeerStyle(Style beerStyle)
        {
            var styleCollection = _database.GetCollection <Style>(StyleCollectionName);

            styleCollection.InsertOne(beerStyle);
        }
Exemplo n.º 3
0
        private Recipe ConvertRecipeToDbRecipe(RecipeGenerationInfoDto recipeGenerationInfoDto, Style style, IRecipe generatedRecipe)
        {
            var recipeToInsert = _mapper.Map <Recipe>(generatedRecipe);

            recipeToInsert.ProjectedOutcome = _mapper.Map <RecipeProjectedOutcome>(recipeGenerationInfoDto);
            recipeToInsert.StyleId          = recipeGenerationInfoDto.StyleId;
            recipeToInsert.YeastId          = style.CommonYeastId;
            for (var i = 0; i < recipeToInsert.FermentableIngredients.Count; i++)
            {
                recipeToInsert.FermentableIngredients[i].FermentableId = style.CommonGrains[i].FermentableId;
            }

            for (var i = 0; i < recipeToInsert.HopIngredients.Count; i++)
            {
                recipeToInsert.HopIngredients[i].HopId = style.CommonHops[i].HopId;
            }

            return(recipeToInsert);
        }
Exemplo n.º 4
0
        private RecipeGenerationInfo GetRecipeGenerationInfo(RecipeGenerationInfoDto recipeGenerationInfoDto, Style style)
        {
            var recipeGenerationInfo = _mapper.Map <RecipeGenerationInfo>(recipeGenerationInfoDto);

            recipeGenerationInfo.Style = GetBeerRecipeCoreStyle(style);
            return(recipeGenerationInfo);
        }
Exemplo n.º 5
0
        private Recipe GenerateRecipe(RecipeGenerationInfoDto recipeGenerationInfoDto, Style style)
        {
            var recipeGenerationInfo = GetRecipeGenerationInfo(recipeGenerationInfoDto, style);

            var generatedRecipe = _recipeService.GenerateRecipe(recipeGenerationInfo);
            var recipeToInsert  = ConvertRecipeToDbRecipe(recipeGenerationInfoDto, style, generatedRecipe);

            return(recipeToInsert);
        }