// GET api/barcode public async Task<List<Beer>> Get(string upc) { try { var beers = new List<Beer>(); foreach(var b in context.Beers) { foreach(var barcode in b.Upcs) { if (barcode == upc) beers.Add(b); } } if(beers.Count > 0) return beers; var properties = new Dictionary<string, string>(); properties.Add("UPC", upc); telemetryClient.TrackEvent("LookupBarcode", properties); var rateBeerClient = new RateBeer.Client(); var results = await rateBeerClient.SearchForBeer(upc); if (results == null) return null; var breweryDbService = new Services.BreweryDBService(); return await breweryDbService.SearchBeers(results.BeerName); } catch(Exception ex) { telemetryClient.TrackException(ex); return null; } }
public async Task<List<Beer>> Get(int takeCount, double longitude = 0, double latitude = 0) { telemetryClient.TrackEvent("GetTrendingBeers"); try { var breweryDb = new Services.BreweryDBService(); var featuredBeers = await breweryDb.GetFeatured(); return featuredBeers.Take(takeCount).ToList(); } catch(Exception ex) { telemetryClient.TrackException(ex); return new List<Beer>(); } }
public async Task <List <Beer> > Get(int takeCount, double longitude = 0, double latitude = 0) { telemetryClient.TrackEvent("GetTrendingBeers"); try { var breweryDb = new Services.BreweryDBService(); var featuredBeers = await breweryDb.GetFeatured(); return(featuredBeers.Take(takeCount).ToList()); } catch (Exception ex) { telemetryClient.TrackException(ex); return(new List <Beer>()); } }
// GET api/barcode public async Task <List <Beer> > Get(string upc) { try { var beers = new List <Beer>(); foreach (var b in context.Beers) { foreach (var barcode in b.Upcs) { if (barcode == upc) { beers.Add(b); } } } if (beers.Count > 0) { return(beers); } var properties = new Dictionary <string, string>(); properties.Add("UPC", upc); telemetryClient.TrackEvent("LookupBarcode", properties); var rateBeerClient = new RateBeer.Client(); var results = await rateBeerClient.SearchForBeer(upc); if (results == null) { return(null); } var breweryDbService = new Services.BreweryDBService(); return(await breweryDbService.SearchBeers(results.BeerName)); } catch (Exception ex) { telemetryClient.TrackException(ex); return(null); } }