Example #1
0
        public List <ConcertfitResponse> Get()
        {
            using (WebClient webClient = new WebClient())
            {
                string jsonDataTicketmaster = webClient.DownloadString("https://concertfitapis20191118021024.azurewebsites.net/api/ticketmaster");
                TicketMasterResponse.TopLevel topLevelTicketMaster = TicketMasterResponse.TopLevel.FromJson(jsonDataTicketmaster);

                string jsonDataSpotify = webClient.DownloadString("https://concertfitapis20191118021024.azurewebsites.net/api/spotify");
                SpotifyArtistsResponse.TopLevel[] topLevelSpotify = SpotifyArtistsResponse.TopLevel.FromJson(jsonDataSpotify);

                List <ConcertfitResponse> concertfitResponseList = new List <ConcertfitResponse>();

                IDictionary <string, TicketMasterResponse.Event> events = new Dictionary <string, TicketMasterResponse.Event>();
                foreach (TicketMasterResponse.Event evnt in topLevelTicketMaster.Embedded.Events)
                {
                    events.TryAdd(evnt.Name, evnt);
                }

                foreach (SpotifyArtistsResponse.TopLevel topLevel in topLevelSpotify)
                {
                    ConcertfitResponse concertfitResponse = new ConcertfitResponse
                    {
                        Artist    = topLevel.Artist,
                        Track     = topLevel.Tracks,
                        EventName = events[topLevel.Artist].Name,
                        EventUrl  = events[topLevel.Artist].Url.ToString(),
                        Dates     = events[topLevel.Artist].Dates
                    };
                    concertfitResponseList.Add(concertfitResponse);
                }

                return(concertfitResponseList);
            }
        }
 public TicketMasterResponse.TopLevel Get()
 {
     using (StreamReader r = new StreamReader("ticketmaster.json"))
     {
         string json = r.ReadToEnd();
         TicketMasterResponse.TopLevel ticketMasterResponseTopLevel = TicketMasterResponse.TopLevel.FromJson(json);
         return(ticketMasterResponseTopLevel);
     }
 }