Beispiel #1
0
        public RecipeController(IRecipeProvider recipeProvider, ICategoryProvider categoryProvider, IIngridientProvider ingridientProvider)
        {
            ProvidersFactory factory = new ProvidersFactory();

            if (recipeProvider != null)
            {
                _recipeProvider = recipeProvider;
            }
            else
            {
                _recipeProvider = factory.GetRecipeProvider();
            }

            if (categoryProvider != null)
            {
                _categoryProvider = categoryProvider;
            }
            else
            {
                _categoryProvider = factory.GetCategoryProvider();
            }

            if (ingridientProvider != null)
            {
                _ingridientProvider = ingridientProvider;
            }
            else
            {
                _ingridientProvider = factory.GetIngridientProvider();
            }
        }
Beispiel #2
0
        public DietController(RequirementsProvider requirementsProvider, NsgaSolverFactory nsgaSolverFactory, IRecipeProvider recipeProvider)
        {
            _requirementsProvider = requirementsProvider;
            _nsgaSolverFactory    = nsgaSolverFactory;
            _recipeProvider       = recipeProvider;

            RInvoker.Path = HostingEnvironment.MapPath(@"~/Content");
        }
Beispiel #3
0
        public RecipeModule(IRecipeProvider recipeProvider) : base("recipe")
        {
            Get("/", ctx =>
            {
                var recipes = recipeProvider.GetAll();
                return(ctx.Response.AsJson(recipes));
            });

            Get("/{id:int}", ctx =>
            {
                var id = ctx.GetRouteData().As <int>("id");

                var recipe = recipeProvider.GetById(id);

                if (recipe != null)
                {
                    return(ctx.Response.AsJson(recipe));
                }
                else
                {
                    ctx.Response.StatusCode = 404;
                    return(ctx.Response.WriteAsync($"No recipe with id {id} was found"));
                }
            });

            Post("/", ctx =>
            {
                var recipe = ctx.Request.Bind <Recipe>();

                var addedRecipe = recipeProvider.Add(recipe);

                return(ctx.Response.AsJson(addedRecipe));
            });

            Put("/{id:int}", ctx =>
            {
                var id        = ctx.GetRouteData().As <int>("id");
                var newRecipe = ctx.Request.Bind <Recipe>();

                if (id != newRecipe.Id)
                {
                    ctx.Response.StatusCode = 400;
                    return(ctx.Response.WriteAsync("Cant update Id property"));
                }

                var editedRecipe = recipeProvider.Update(id, newRecipe);
                return(ctx.Response.AsJson(editedRecipe));
            });

            Delete("/{id:int}", ctx =>
            {
                var id = ctx.GetRouteData().As <int>("id");
                recipeProvider.Delete(id);
                ctx.Response.StatusCode = 204;
                return(Task.CompletedTask);
            });
        }
Beispiel #4
0
 public RecipesController(
     ICookingProcedureProvider cookingProcedureProvider,
     IIngredientProvider ingredientProvider,
     IIngredientMapper ingredientMapper,
     IRecipeProvider recipeProvider,
     IRecipeMapper recipeMapper,
     IPdfGenerator pdfGenerator,
     IScraper scraper,
     IRecipeParser RecipeParser,
     ISiteSettingsProvider siteSettingsProvider,
     IFileHandler fileHandler
     )
 {
     this.cookingProcedureProvider = cookingProcedureProvider;
     this.ingredientProvider       = ingredientProvider;
     this.ingredientMapper         = ingredientMapper;
     this.recipeProvider           = recipeProvider;
     this.recipeMapper             = recipeMapper;
     this.pdfGenerator             = pdfGenerator;
     this.scraper              = scraper;
     this.RecipeParser         = RecipeParser;
     this.siteSettingsProvider = siteSettingsProvider;
     this.fileHandler          = fileHandler;
 }
 public void PrintRecipe(IRecipeProvider recipe)
 {
     File.WriteAllText("Recipe.txt", recipe.GetTextToPrint());
 }
 public FetchDataViewModels(IRecipeProvider recipeProvider)
 {
     _recipeProvider = recipeProvider;
 }
Beispiel #7
0
 public App(IRecipeProvider recipeProvider, ILogger <App> logger)
 {
     this.recipeProvider = recipeProvider ?? throw new ArgumentNullException(nameof(recipeProvider));
     this.logger         = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public RecipeLookup(IRecipeProvider provider, IConfiguration config)
 {
     _provider = provider;
     _config   = config;
 }
Beispiel #9
0
 public void RemoveRecipeProvider(IRecipeProvider provider)
 {
     Mod.Recipes.RemoveProvider(provider);
 }
Beispiel #10
0
 public void AddRecipeProvider(IRecipeProvider provider)
 {
     Mod.Recipes.AddProvider(provider);
 }
 public RecipeController(IRecipeProvider recipeProvider)
 {
     _recipeProvider = recipeProvider;
 }
Beispiel #12
0
 public SearchController(
     IRecipeProvider recipeProvider
     )
 {
     this.recipeProvider = recipeProvider;
 }
 public void PrintRecipe(IRecipeProvider recipe)
 {
     Console.WriteLine(recipe.GetTextToPrint());
 }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RecipeDownload"/> class.
 /// </summary>
 /// <param name="recipeRepository">The recipe repository.</param>
 /// <param name="recipeProvider">The recipe provider.</param>
 /// <param name="logger">The logger.</param>
 public RecipeDownload(
     IRecipeRepository recipeRepository,
     IRecipeProvider recipeProvider,
     ILogger logger)
 => (_recipeRepository, _recipeProvider, _logger) = (recipeRepository, recipeProvider, logger);
Beispiel #15
0
 public MealPlanGenerator(IRecipeProvider recipeProvider)
 {
     _recipeProvider = recipeProvider;
 }
Beispiel #16
0
 public TagsController(
     IRecipeProvider recipeProvider
     )
 {
     this.recipeProvider = recipeProvider;
 }