// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.AddRazorPages(); var apiKey = Configuration["apiKey"]; var spoonacularConfig = new SpoonacularConfiguration() { ApiKey = apiKey }; services.AddSingleton(spoonacularConfig); services.AddSingleton <ConcurrentDictionary <int, Recipe> >(); services.AddHttpClient <ISearchRecipe, RecipeClientWithCache>(client => { client.BaseAddress = new Uri("https://api.spoonacular.com/"); }); services.AddDbContext <GC_PlanMyMealIdentityDbContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:PlanMyMealDb"])); services.AddScoped <IRepositoryClient, RepositoryClient>(); services.AddScoped <IPreferencesClient, PreferencesClient>(); services.AddDefaultIdentity <IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores <GC_PlanMyMealIdentityDbContext>(); }
public RecipeClient(HttpClient httpClient, SpoonacularConfiguration config) { _httpClient = httpClient; _config = config; }
public RecipeClientWithCache(HttpClient httpClient, SpoonacularConfiguration config, ConcurrentDictionary <int, Recipe> recipeCache) : base(httpClient, config) { _recipeCache = recipeCache; }