Beispiel #1
0
 //Constructor for Dependency Injection
 public FavoritesController(IConfiguration configuration, SnacksDbContext context)
 {
     _yelpKey            = configuration.GetSection("ApiKeys")["YelpApi"];
     _client             = new HttpClient();
     _client.BaseAddress = new Uri("https://api.yelp.com/v3/");
     _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _yelpKey);
     _context = context;
 }
 //Injected our database context and the configuration for our API keys.
 public ReviewController(IConfiguration configuration, SnacksDbContext context)
 {
     //Telling our program where to find our APIs and then starting a new API call
     //with the necessary base address and Header.
     _yelpKey            = configuration.GetSection("ApiKeys")["YelpApi"];
     _client             = new HttpClient();
     _client.BaseAddress = new Uri("https://api.yelp.com/v3/");
     _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _yelpKey);
     _context = context;
 }
 public SnackController(IConfiguration configuration, SnacksDbContext context)
 {
     //Dependancy injecting our snacks controller
     _yelpKey = configuration.GetSection("ApiKeys")["YelpApi"];
     _client  = new HttpClient();
     //Setting up the Base address and necessary header for our Yelp API calls
     _client.BaseAddress = new Uri("https://api.yelp.com/v3/");
     _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _yelpKey);
     _context = context;
 }
 public HomeController(ILogger <HomeController> logger, SnacksDbContext context)
 {
     _logger  = logger;
     _context = context;
 }