Пример #1
0
        private void AddCheckin(Checkin checkin, CheckinsContainer checkinsContainer)
        {
            Beer beer = checkinsContainer.GetBeer(checkin.Beer.Id);

            if (beer == null)
            {
                beer = checkin.Beer;
                Brewery brewery = checkinsContainer.GetBrewery(beer.Brewery.Id);
                if (brewery == null)
                {
                    brewery = beer.Brewery;
                    Venue venue = brewery.Venue;
                    if (IsUpdateVenue(ref venue, checkinsContainer))
                    {
                        brewery.Venue = venue;
                    }

                    checkinsContainer.AddBrewery(brewery);
                }
                else
                {
                    beer.Brewery = brewery;
                }
                checkinsContainer.AddBeer(beer);
            }
            else
            {
                checkin.Beer = beer;
            }

            FillCheckinVenue(checkin, checkinsContainer);
            checkinsContainer.AddCheckin(checkin);
        }
Пример #2
0
 private static void FillVenue(Venue venue, VenueWeb venueWeb)
 {
     venue.Id        = venueWeb.VenueId;
     venue.Name      = venueWeb.VenueName;
     venue.Country   = venueWeb.Location.VenueCountry;
     venue.State     = venueWeb.Location.VenueState;
     venue.City      = venueWeb.Location.VenueCity;
     venue.Latitude  = venueWeb.Location.Lat;
     venue.Longitude = venueWeb.Location.Lng;
 }
Пример #3
0
        private static bool IsUpdateVenue(ref Venue venue, CheckinsContainer checkinsContainer)
        {
            Venue existVenue = checkinsContainer.GetVenue(venue);

            if (existVenue != null)
            {
                venue = existVenue;
                return(true);
            }
            checkinsContainer.AddVenue(venue);
            return(false);
        }
Пример #4
0
        private static void FillCheckinVenue(Checkin checkin, CheckinsContainer checkinsContainer)
        {
            Venue existVenue = checkinsContainer.GetVenue(checkin.Venue);

            if (existVenue != null)
            {
                checkin.Venue = existVenue;
            }
            else
            {
                checkinsContainer.AddVenue(checkin.Venue);
            }
        }