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;
}
}