public async Task Handle(IngredientUpdatedEvent @event)
        {
            var recipesIds = await _recipeDetailsRepository.GetRecipeIdsByIngredientId(@event.IngredientId);

            var recipeDetailsCollection = new List <RecipeDetails>();

            foreach (var recipesId in recipesIds)
            {
                var recipeDetails = await _recipeDetailsFactory.Create(recipesId);

                recipeDetailsCollection.Add(recipeDetails);
            }
            await _recipeDetailsRepository.CreateNewOrReplaceExistingRange(recipeDetailsCollection);
        }
Esempio n. 2
0
        private async Task AddRecipe(RecipeViewModel recipeViewModel)
        {
            // Load data
            var detailsVm = _detailsFactory.Create(recipeViewModel.Type);
            await detailsVm.Load(recipeViewModel, _workplans);

            // If we are currently in edit mode, we enter it
            if (IsEditMode)
            {
                detailsVm.BeginEdit();
            }

            Items.Add(detailsVm);
        }
        private async Task Build()
        {
            var recipesIds = await _recipeDetailsRepository.GetAllRecipesIds();

            var recipeDetailsCollection = new List <RecipeDetails>();

            foreach (var recipesId in recipesIds)
            {
                var recipeDetails = await _recipeDetailsFactory.Create(recipesId);

                recipeDetailsCollection.Add(recipeDetails);
            }
            await _recipeDetailsRepository.CreateNewOrReplaceExistingRange(recipeDetailsCollection);
        }
        public async Task Handle(RecipeCreatedEvent @event)
        {
            var recipeDetails = await _recipeDetailsFactory.Create(@event.RecipeId);

            await _recipeDetailsRepository.CreateNewOrReplaceExisting(recipeDetails);
        }