public BeerDetails(BreweryDB.Models.Beer beer) { Title = beer.Name; name = new Label { Text = beer.Name, FontSize = 20, }; description = new Label { Text = beer.Description, FontSize = 10 }; image = new Image { Source = beer.Labels.Medium }; Content = new ScrollView { Content = new StackLayout { Padding = 10, Children = {image, name, description} } }; }
//Beer Converter Beer ToBeerDrinkin(BreweryDB.Interfaces.IBeer dbBeer) { try { var beer = new Beer() { Id = dbBeer.Id, Name = dbBeer.Name, BreweryDbId = dbBeer.Id, Description = dbBeer.Description, Abv = dbBeer.Abv }; if (dbBeer.Labels != null) { var image = new Image { SmallUrl = dbBeer?.Labels?.Icon, MediumUrl = dbBeer?.Labels?.Medium, LargeUrl = dbBeer?.Labels?.Large }; beer.Image = image; } if (dbBeer.Breweries.Count != 0) { var dbBrewery = dbBeer.Breweries.FirstOrDefault(); beer.Brewery = ToBeerDrinkin(dbBrewery); } return beer; } catch (Exception ex) { telemetryClient.TrackException(ex); return null; } }
//Brewery Converter Brewery ToBeerDrinkin(BreweryDB.Interfaces.IBrewery dbBrewery) { try { var brewery = new Brewery(); brewery.Name = dbBrewery.Name; brewery.Description = dbBrewery.Description; brewery.Id = dbBrewery.Id; brewery.Website = dbBrewery.Website; if (dbBrewery.Image != null) { var image = new Image { LargeUrl = dbBrewery.Image.Large, MediumUrl = dbBrewery.Image.Medium, SmallUrl = dbBrewery.Image.Icon }; brewery.Image = image; } return brewery; } catch (Exception ex) { telemetryClient.TrackException(ex); return null; } }
public void Initialize() { breweryDbApi = new BreweryDB(GetSecret("BreweryDbApiKey")); }