public void Handle(AddProductToDiaryCommand command)
        {
            var product = _context.Products.First(p => p.ProductId == command.ProductId);

            DiaryHelper.AddProductToDiary(_context, command.AmountConsumed, product, command.MealId, command.ConsumedDate);
            _context.SaveChanges();
        }
        public void Handle(AddRecipeToDiaryCommand command)
        {
            var recipe = _context.Recipes
                         .Include(r => r.Ingredients.Select(i => i.Product))
                         .First(r => r.RecipeId == command.RecipeId);

            var servingsRatio = (decimal)command.NumberOfServingsConsumed / recipe.Servings;

            foreach (var ingredient in recipe.Ingredients)
            {
                var amountConsumed = (int)Math.Round(ingredient.Amount * servingsRatio, 0, MidpointRounding.AwayFromZero);
                DiaryHelper.AddProductToDiary(_context, amountConsumed, ingredient.Product, command.MealId, command.ConsumedDate);
            }

            _context.SaveChanges();
        }