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);
        }
        public void CreateBeerStyle(Style beerStyle)
        {
            var styleCollection = _database.GetCollection <Style>(StyleCollectionName);

            styleCollection.InsertOne(beerStyle);
        }
        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);
        }
        private RecipeGenerationInfo GetRecipeGenerationInfo(RecipeGenerationInfoDto recipeGenerationInfoDto, Style style)
        {
            var recipeGenerationInfo = _mapper.Map <RecipeGenerationInfo>(recipeGenerationInfoDto);

            recipeGenerationInfo.Style = GetBeerRecipeCoreStyle(style);
            return(recipeGenerationInfo);
        }
        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);
        }