Exemplo n.º 1
0
        /// <summary>
        /// Search for setlists.
        /// </summary>
        /// <param name="searchFields">
        /// You must provide a value for at least one of the following properties:
        /// <para>Tour, LastUpdated, EventDate (you could set only a year, e.g. <code>00-00-2007</code>),</para>
        /// <para>Artist.Name, Artist.MBID, Artist.TMID (set <code>TMIDSpecified = true</code>)</para>
        /// <para>Venue.Id, Venue.Name, Venue.City.Id, Venue.City.Name. Venue.City.State, Venue.City.State.Code, Venue.City.Country.Code</para>
        /// </param>
        /// <param name="page">Page number to fetch.</param>
        /// <returns>A list of matching setlists.</returns>
        public List <Setlists> SearchSetlists(Setlist searchFields)
        {
            StringBuilder query = new StringBuilder();

            if (searchFields != null)
            {
                if (!string.IsNullOrEmpty(searchFields.TourName))
                {
                    query.AppendFormat("tour={0}&", searchFields.Tour);
                }
                if (!string.IsNullOrEmpty(searchFields.LastUpdated))
                {
                    query.AppendFormat("lastUpdate={0}&", searchFields.LastUpdated);
                }
                if (!string.IsNullOrEmpty(searchFields.EventDate))
                {
                    if (searchFields.GetEventDateTime() != null)
                    {
                        query.AppendFormat("date={0}&", searchFields.EventDate);
                    }
                    else
                    if (searchFields.GetYear() != 0)
                    {
                        query.AppendFormat("year={0}&", searchFields.GetYear());
                    }
                }

                if (searchFields.Artist != null)
                {
                    if (!string.IsNullOrEmpty(searchFields.Artist.MBID))
                    {
                        query.AppendFormat("artistMbid={0}&", searchFields.Artist.MBID);
                    }
                    if (searchFields.Artist.TMIDSpecified)
                    {
                        query.AppendFormat("artistTmid={0}&", searchFields.Artist.TMID);
                    }
                    if (!string.IsNullOrEmpty(searchFields.Artist.Name))
                    {
                        query.AppendFormat("artistName={0}&", searchFields.Artist.Name);
                    }
                }
                if (searchFields.Venue != null)
                {
                    if (!string.IsNullOrEmpty(searchFields.Venue.Id))
                    {
                        query.AppendFormat("venueId={0}&", searchFields.Venue.Id);
                    }
                    if (!string.IsNullOrEmpty(searchFields.Venue.Name))
                    {
                        query.AppendFormat("venueName={0}&", searchFields.Venue.Name);
                    }

                    if (searchFields.Venue.City != null)
                    {
                        if (searchFields.Venue.City.Id != "0" && searchFields.Venue.City.Id != "")
                        {
                            query.AppendFormat("cityId={0}&", searchFields.Venue.City.Id);
                        }
                        if (!string.IsNullOrEmpty(searchFields.Venue.City.Name))
                        {
                            query.AppendFormat("cityName={0}&", searchFields.Venue.City.Name);
                        }
                        if (!string.IsNullOrEmpty(searchFields.Venue.City.State))
                        {
                            query.AppendFormat("state={0}&", searchFields.Venue.City.State);
                        }
                        if (!string.IsNullOrEmpty(searchFields.Venue.City.StateCode))
                        {
                            query.AppendFormat("stateCode={0}&", searchFields.Venue.City.StateCode);
                        }

                        if (searchFields.Venue.City.Country != null)
                        {
                            if (!string.IsNullOrEmpty(searchFields.Venue.City.Country.Code))
                            {
                                query.AppendFormat("countryCode={0}&", searchFields.Venue.City.Country.Code);
                            }
                        }
                    }
                }
            }

            string url = string.Format("/search/setlists?{0}p=1", query.ToString());

            List <Setlists> setlists = new List <Setlists>();

            setlists.Add(Load <Setlists>(url));


            int cicli = setlists[0].TotalPages;

            for (int i = 2; i < cicli - 1; i++)
            {
                url = string.Format("/search/setlists?{0}p={1}", query.ToString(), i.ToString());

                setlists.Add(Load <Setlists>(url));
            }


            return(setlists);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Search for setlists.
        /// </summary>
        /// <param name="searchFields">
        /// You must provide a value for at least one of the following properties:
        /// <para>Tour, LastUpdated, EventDate (you could set only a year, e.g. <code>00-00-2007</code>),</para>
        /// <para>Artist.Name, Artist.MBID, Artist.TMID (set <code>TMIDSpecified = true</code>)</para>
        /// <para>Venue.Id, Venue.Name, Venue.City.Id, Venue.City.Name. Venue.City.State, Venue.City.State.Code, Venue.City.Country.Code</para>
        /// </param>
        /// <param name="page">Page number to fetch.</param>
        /// <returns>A list of matching setlists.</returns>
        public Setlists SearchSetlists(Setlist searchFields, int page = 1)
        {
            StringBuilder query = new StringBuilder();

            if (searchFields != null)
            {
                if (!string.IsNullOrEmpty(searchFields.TourName))
                {
                    query.AppendFormat("tour={0}&", searchFields.Tour);
                }
                if (!string.IsNullOrEmpty(searchFields.LastUpdated))
                {
                    query.AppendFormat("lastUpdate={0}&", searchFields.LastUpdated);
                }
                if (!string.IsNullOrEmpty(searchFields.EventDate))
                {
                    if (searchFields.GetEventDateTime() != null)
                    {
                        query.AppendFormat("date={0}&", searchFields.EventDate);
                    }
                    else
                    if (searchFields.GetYear() != 0)
                    {
                        query.AppendFormat("year={0}&", searchFields.GetYear());
                    }
                }

                if (searchFields.Artist != null)
                {
                    if (!string.IsNullOrEmpty(searchFields.Artist.MBID))
                    {
                        query.AppendFormat("artistMbid={0}&", searchFields.Artist.MBID);
                    }
                    if (searchFields.Artist.TMIDSpecified)
                    {
                        query.AppendFormat("artistTmid={0}&", searchFields.Artist.TMID);
                    }
                    if (!string.IsNullOrEmpty(searchFields.Artist.Name))
                    {
                        query.AppendFormat("artistName={0}&", searchFields.Artist.Name);
                    }
                }
                if (searchFields.Venue != null)
                {
                    if (!string.IsNullOrEmpty(searchFields.Venue.Id))
                    {
                        query.AppendFormat("venueId={0}&", searchFields.Venue.Id);
                    }
                    if (!string.IsNullOrEmpty(searchFields.Venue.Name))
                    {
                        query.AppendFormat("venueName={0}&", searchFields.Venue.Name);
                    }

                    if (searchFields.Venue.City != null)
                    {
                        if (searchFields.Venue.City.Id != "0" && searchFields.Venue.City.Id != "")
                        {
                            query.AppendFormat("cityId={0}&", searchFields.Venue.City.Id);
                        }
                        if (!string.IsNullOrEmpty(searchFields.Venue.City.Name))
                        {
                            query.AppendFormat("cityName={0}&", searchFields.Venue.City.Name);
                        }
                        if (!string.IsNullOrEmpty(searchFields.Venue.City.State))
                        {
                            query.AppendFormat("state={0}&", searchFields.Venue.City.State);
                        }
                        if (!string.IsNullOrEmpty(searchFields.Venue.City.StateCode))
                        {
                            query.AppendFormat("stateCode={0}&", searchFields.Venue.City.StateCode);
                        }

                        if (searchFields.Venue.City.Country != null)
                        {
                            if (!string.IsNullOrEmpty(searchFields.Venue.City.Country.Code))
                            {
                                query.AppendFormat("countryCode={0}&", searchFields.Venue.City.Country.Code);
                            }
                        }
                    }
                }
            }

            string   url      = string.Format("/search/setlists?{0}p={1}", query.ToString(), page.ToString());
            Setlists setlists = Load <Setlists>(url);

            return(setlists);
        }