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))); }
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)); }
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"); }
public void RemoveDuplicates() { var allEvents = _eventSearchService.GetVenueEvents(new GetEventsConfiguration()).ToList(); for (var i = 0; i < allEvents.Count; i++) { for (var j = i + 1; j < allEvents.Count; j++) { if (AreEqual(allEvents[i], allEvents[j])) { var oldestContent = Oldest(allEvents[i], allEvents[j]); Delete(oldestContent); } } } }