Example #1
0
        public static Task <Beer> ConvertBeer([QueueTrigger("queue")] BreweryDB.Models.Beer beer, TextWriter log)
        {
            log.WriteLine($"Converting {beer.Name}");

            return(null);
        }
Example #2
0
        public static Beer ToBeerItem(this BreweryDB.Models.Beer breweryDbBeer, Beer beer = null)
        {
            try
            {
                if (beer == null)
                {
                    beer = new Beer
                    {
                        Id          = breweryDbBeer.Id,
                        BreweryDbId = breweryDbBeer.Id,

                        Name        = breweryDbBeer?.Name,
                        Description = breweryDbBeer?.Description,
                        ABV         = breweryDbBeer?.Abv
                    };
                }

                //Check for BreweryData
                if (breweryDbBeer.Breweries != null || breweryDbBeer.Breweries.Count > 0)
                {
                    var breweryDbBrewery = breweryDbBeer?.Breweries?.FirstOrDefault();
                    if (breweryDbBrewery != null)
                    {
                        var brewery = new Brewery();
                        brewery.Name        = breweryDbBrewery?.Name;
                        brewery.Description = breweryDbBrewery?.Description;
                        if (breweryDbBrewery.Image != null)
                        {
                            brewery.ImageUrls = new Images()
                            {
                                Icon   = breweryDbBrewery.Image?.Icon,
                                Medium = breweryDbBrewery.Image?.Medium,
                                Large  = breweryDbBrewery.Image?.Large
                            }
                        }
                        ;

                        brewery.IsOrganic = breweryDbBrewery?.IsOrganic == "Y";
                        brewery.Website   = breweryDbBrewery?.Website;
                        beer.Brewery      = brewery;
                    }
                }

                beer.ABV = breweryDbBeer?.Abv;
                if (breweryDbBeer.Labels == null)
                {
                    return(beer);
                }

                var images = new Images()
                {
                    Icon   = breweryDbBeer.Labels.Icon,
                    Medium = breweryDbBeer.Labels.Medium,
                    Large  = breweryDbBeer.Labels.Large
                };
                beer.Images = images;

                return(beer);
            }
            catch (Exception ex)
            {
                telemetry.TrackException(ex);
            }
            return(null);
        }