GetAllArtist() public method

public GetAllArtist ( string artistName ) : IEnumerable
artistName string
return IEnumerable
コード例 #1
0
        // get : api/Movies?type={current/all (default)}&resultlimit={default 100}
        protected override string ProcessRequest()
        {
            int resultLimit = 15;

            // get query string parameters
            string queryParameters = this.Request.RequestUri.Query;
            if (queryParameters != null)
            {
                var tableMgr = new TableManager();
                var qpParams = HttpUtility.ParseQueryString(queryParameters);

                string artistsInitials = string.Empty;

                if (!string.IsNullOrEmpty(qpParams["q"]))
                {
                    artistsInitials = qpParams["q"].ToString().ToLower();
                }

                var artistsByName = tableMgr.GetAllArtist(artistsInitials.ToLower()).Take(resultLimit).ToList().OrderBy(a => a.ArtistName);
                return jsonSerializer.Value.Serialize(artistsByName);
            }

            return string.Empty;
        }
コード例 #2
0
        protected override string ProcessRequest()
        {
            string userFeedbackTags;
            if (!CacheManager.TryGet<string>(CacheConstants.UserFeedback, out userFeedbackTags))
            {
                try
                {
                    // Get top actors
                    // Get top music directors
                    // Currently we don't have any mechanism to map/track the role of artists
                    // E.g. AR Rehman is for music director. Complexity arises for Farhan Akhtar kind of person (multi talented)

                    // hard code genre & critics
                    var tableMgr = new TableManager();
                    List<ArtistEntity> artistList = tableMgr.GetAllArtist(string.Empty).ToList();

                    foreach (ArtistEntity ae in artistList)
                    {
                        ae.ArtistId = string.Empty;
                        ae.Bio = string.Empty;
                        ae.Born = string.Empty;
                        ae.Popularity = string.IsNullOrEmpty(ae.Popularity) ? "0" : ae.Popularity;
                        ae.JsonString = string.Empty;
                        ae.ETag = string.Empty;
                        ae.PartitionKey = string.Empty;
                        ae.RowKey = string.Empty;
                    }

                    IEnumerable<ArtistEntity> artistList1 = artistList.OrderByDescending(a => int.Parse(a.Popularity)).Take(5);

                    //IEnumerable<ArtistEntity> artistList = tableMgr.GetAllArtist(string.Empty).OrderByDescending(a => int.Parse(a.Popularity)).Take(5);

                    var roleReviewer = new string[] { "Anupama Chopra", "Taran Adarsh", "Rajeev Masand", "Komal Nahta" }
                        .Select(r => new
                        {
                            UniqueName = r.ToLower().Replace(" ", "-"),
                            Name = r,
                            Role = "Reviewer",
                            Weight = "3",
                        });

                    //IDictionary<string, MovieEntity> movieEntities = tableMgr.GetAllMovies();
                    // Music directors
                    // Get music directors name
                    // search in DB against list of these names - find which one is most popular based on the
                    // popularity column in artists table

                    // directors & producers
                    // Get director + producers name
                    // search in DB agains list of these names - find which one is most popular based on the
                    // popularity column in artist table

                    /*var musicDirectors = movieEntities
                        .SelectMany(m => m.Value.GetMusicDirectors())
                        .GroupBy(g => g)
                        .OrderByDescending(g => g.Count())
                        .Take(4);

                    var directors = movieEntities
                        .SelectMany(m => m.Value.GetProducers()
                                          .Concat(m.Value.GetDirectors()))
                        .GroupBy(g => g)
                        .OrderByDescending(g => g.Count())
                        .Take(4);

                    */

                    var popular = string.Format(
                        "[{0},{1}]",
                        jsonSerializer.Value.Serialize(artistList1),
                        jsonSerializer.Value.Serialize(roleReviewer));
                    //jsonSerializer.Value.Serialize(musicDirectors),
                    //jsonSerializer.Value.Serialize(directors));

                    userFeedbackTags = popular;

                    CacheManager.Add<string>(CacheConstants.UserFeedback, userFeedbackTags);
                }
                catch (Exception)
                {
                    // if any error occured then return User friendly message with system error message
                    return jsonError.Value;
                }
            }

            return userFeedbackTags;
        }