Beispiel #1
0
        // TODO: Is there a sensible way to reuse the logic in here?
        private void ValidateLocationSelection(GetEventsConfiguration configuration)
        {
            if (!configuration.CountryId.HasValue)
            {
                configuration.CityId  = null;
                configuration.VenueId = null;
                return;
            }

            var validCities = _umbracoWrapper.TypedContent(configuration.CountryId.Value)
                              .Children;

            if (!configuration.CityId.HasValue || validCities.All(x => x.Id != configuration.CityId))
            {
                configuration.CityId  = null;
                configuration.VenueId = null;
                return;
            }

            var validVenues = _umbracoWrapper.TypedContent(configuration.CityId.Value)
                              .Children;

            if (!configuration.VenueId.HasValue || validVenues.All(x => x.Id != configuration.VenueId.Value))
            {
                configuration.VenueId = null;
            }
        }
Beispiel #2
0
        public ActionResult Index(RenderModel model, GetEventsConfiguration configuration)
        {
            // TODO: These two methods might be worth moving into MVC attributes
            OverridePaging(configuration);
            ValidateLocationSelection(configuration);

            // TODO: A lot of this code could be refactored out into a service
            var selectedLocationNode = configuration.LocationId.HasValue
                                ? _umbracoWrapper.TypedContent(configuration.LocationId.Value)
                                : model.Content;
            var viewModel = _modelConverter.ToModel <FeedViewModel>(selectedLocationNode);

            viewModel.Countries = Countries(model.Content, configuration);

            if (!configuration.CountryId.HasValue)
            {
                configuration.CountryId = viewModel.Countries.First().Id;
            }

            viewModel.Cities = SubLocations(configuration.CountryId, configuration.CityId);
            viewModel.Venues = SubLocations(configuration.CityId, configuration.VenueId);
            viewModel.Events = _eventSearchService.GetVenueEvents(configuration).ToModel <EventViewModel>();

            return(View("~/Views/Feed.cshtml", viewModel));
        }
Beispiel #3
0
        public object FeedEvents(GetEventsConfiguration configuration)
        {
            var results      = _eventSearchService.GetVenueEvents(configuration);
            var typedResults = results.ToModel <EventViewModel>();

            // TODO: Generic API Response type
            return(JsonConvert.SerializeObject(new ApiSuccessResponse(typedResults)));
        }
Beispiel #4
0
        public object MapEvents(GetEventsConfiguration configuration)
        {
            var results        = _eventSearchService.GetVenueEvents(configuration);
            var groupedResults = results.GroupBy(x => x.Parent.Id).Select(ToVenueViewModel).ToList();

            // TODO: Generic API Response type
            return(JsonConvert.SerializeObject(new ApiSuccessResponse(groupedResults)));
        }
Beispiel #5
0
 public IEnumerable <LocationOption> Countries(IPublishedContent content, GetEventsConfiguration configuration)
 {
     return(_umbracoWrapper.AncestorOrSelf(content, 1)
            .Children
            .First(x => x.DocumentTypeAlias.Equals("locations"))
            .Children
            .Where(x => x.Children.Any())
            .Select(x => Option(x, configuration.CountryId))
            .ToList());
 }
Beispiel #6
0
        public IEnumerable <LiveLinkEvent> GetEventsForVenue(IPublishedContent venueContent, int?limit)
        {
            var identifier = _umbracoWrapper
                             .GetPropertyValue <string>(venueContent, "developerFacebookPageIdentifier");

            var eventsConfiguration = new FacebookEventsOptions
            {
                Limit = limit
            };

            var config   = new GetEventsConfiguration(eventsConfiguration, identifier);
            var response = _getEventsCall.Call(config);

            return(AsLiveLinkEvents(response.Events, venueContent.Id));
        }
Beispiel #7
0
        public object Debug()
        {
            Log($"START: Gathering events to cleanup");

            var config = new GetEventsConfiguration
            {
                EarliestDate = DateTime.MinValue,
                LatestDate   = _dateTimeProvider.Now().AddDays(-3)
            };

            Log(
                $"Config: {config.EarliestDate.Value.ToString("yyyy MMMM dd")} -> {config.LatestDate.Value.ToString("yyyy MMMM dd")}");

            var results = _eventSearchService.GetVenueEvents(config);

            if (!results.Any())
            {
                Log($"NO RESULTS FOUND");
            }

            foreach (var publishedContent in results)
            {
                var startDate = _umbracoWrapper.GetPropertyValue <DateTime>(publishedContent, "contentStartDateTime");
                if (startDate > _dateTimeProvider.Now().AddDays(-2))
                {
                    Log(
                        $"Event is NOT in cleanup date range! {publishedContent.Id}|{publishedContent.Name}|STARTS:{startDate.ToString("yyyy MMMM dd")}");
                }
                else
                {
                    Log($"Event is in cleanup date range {publishedContent.Id}|{publishedContent.Name}");
                }
            }

            Log($"COMPLETE: Gathering events to cleanup");

            return("OK");
        }
Beispiel #8
0
 private void OverridePaging(GetEventsConfiguration configuration)
 {
     configuration.Page         = 1;
     configuration.ItemsPerPage = 12;
 }