Beispiel #1
0
        internal List <TicketmasterEvent> SearchEvent(string latLong, string unit, string radius, DateTime startDate)
        {
            var list = new List <TicketmasterEvent>();

            try
            {
                var request = new SearchEventsRequest();
                request.AddQueryParameter(SearchEventsQueryParameters.latlong, latLong);
                request.AddQueryParameter(SearchEventsQueryParameters.unit, unit);
                request.AddQueryParameter(SearchEventsQueryParameters.radius, radius);
                request.AddQueryParameter(SearchEventsQueryParameters.startDateTime, startDate.ToString("yyyy-MM-ddThh:mm:ssZ"));
                request.AddQueryParameter(SearchEventsQueryParameters.size, "50");
                SearchEventsResponse result = EventsClient.SearchEventsAsync(request).GetAwaiter().GetResult();

                foreach (var _event in result._embedded.Events)
                {
                    var newEvent = new TicketmasterEvent();
                    newEvent.Name           = _event.Name;
                    newEvent.Url            = _event.Url;
                    newEvent.ExternalId     = _event.Id;
                    newEvent.ImageUrl       = _event.Images.First(x => x.Ratio == "16_9").Url;
                    newEvent.Promoter       = _event.Promoter.Name;
                    newEvent.SalesStartDate = _event.Sales.Public.StartDateTime;
                    newEvent.SalesEndDate   = _event.Sales.Public.EndDateTime;
                    newEvent.StartDate      = _event.Dates.Start.DateTime;
                    newEvent.Segment        = _event.Classifications.First().Segment.Name;
                    newEvent.SubGenre       = _event.Classifications.First().SubGenre.Name;
                    newEvent.Genre          = _event.Classifications.First().Genre.Name;

                    list.Add(newEvent);
                }

                return(list);
            }
            catch (Exception)
            {
                return(null);
            }
        }
 public TicketmasterEvent AddTicketmasterEvent(TicketmasterEvent ticketmasterEvent)
 {
     context.TicketmasterEvents.Add(ticketmasterEvent);
     context.SaveChanges();
     return(ticketmasterEvent);
 }