Esempio n. 1
0
        public async Task <Result> Handle(CreateRecipeCommand command)
        {
            foreach (var validator in _validators)
            {
                var validationResult = validator.Validate(command);
                if (validationResult.IsFailure)
                {
                    return(validationResult);
                }
            }

            // var imageUrl = _imageUploader.Upload(command.Image, command.Id.ToString(), command.Name);

            var recipeIngredients = command.RecipeIngredients.Select(x =>
                                                                     _recipeIngredientFactory.Create(x.IngredientId, x.Grams));

            await _recipeFactory.Create(command.Id,
                                        command.Name,
                                        command.Description,
                                        "imageUrl",
                                        command.RecipeInfo,
                                        recipeIngredients);

            _eventPublisher.Rise();
            return(Result.Ok());
        }
    public string AddRecipeToHero(IList <string> arguments)
    {
        var heroName = arguments[1];
        var recipe   = recipeFactory.Create(arguments);

        this.heroes[heroName].AddRecipe(recipe);

        return(string.Format(Constants.RecipeCreatedMessage, recipe.Name, heroName));
    }
Esempio n. 3
0
 public async Task <IEnumerable <Recipe> > GetAllAsync(SuggestionParameters suggestionParameters)
 => await recipeFactory
 .Create(suggestionParameters.Type)
 .RetrieveRecipesAsync(await CreateIngredient(suggestionParameters.Ingredient));