using System.Collections.Generic; using System.Linq; using Sony.Filtr.Contracts.Definitions; using Sony.Filtr.Contracts.Entities; namespace Sony.Filtr.Search.SearchItems { public class PlaylistSearchIndexItem { public PlaylistSearchIndexItem() { } public PlaylistSearchIndexItem(ExtendedEditorialPlaylist extendedEditorialPlaylist, List playlistCategories) { var editorialPlaylist = extendedEditorialPlaylist.EditorialPlaylist; Id = editorialPlaylist.ID; Name = editorialPlaylist.Name; SpotifyUri = editorialPlaylist.SpotifyLinkUri; TypeName = typeof (PlaylistSearchIndexItem).Name; ApplicationId = editorialPlaylist.ApplicationID; Priority = editorialPlaylist.PriorityLevel; ImageUrl = editorialPlaylist.SpotifyImageFileName; if (editorialPlaylist.CountryCode != null) CountryCode = editorialPlaylist.CountryCode.ToLower(); if (editorialPlaylist.SpotifyDescription != null) Description = CloudSearchUnicodeHelper.RemoveInvalidChars(editorialPlaylist.SpotifyDescription); if (editorialPlaylist.Genres.Any()) Tags = editorialPlaylist.Genres.Select(g => g.Genre).Take(100).ToList(); if (editorialPlaylist.Artists.Any()) Artists = editorialPlaylist.Artists.Select(a => a.Artist.Name).Take(100).ToList(); if (editorialPlaylist.Tracks.Any()) Tracks = editorialPlaylist.Tracks.Select(t => t.Name).Take(100).ToList(); IsEditorialPlaylist = true; ServiceType = ServiceType.Spotify; Owner = extendedEditorialPlaylist.EditorialPlaylist.OwnerUsername; if (extendedEditorialPlaylist.Attributes != null) { Followers = extendedEditorialPlaylist.Attributes.Followers; } Categories = new List(); if (playlistCategories != null && playlistCategories.Any()) Categories = playlistCategories.Select(c => c.Name).Union(playlistCategories.Select(c => c.Description)).Where(c=> !string.IsNullOrWhiteSpace(c)).ToList(); BuzzCategoryId = editorialPlaylist.BuzzCategoryId; } public int Id { get; set; } public string Name { get; set; } public string SpotifyUri { get; set; } public string Owner { get; set; } public string TypeName { get; set; } public int ApplicationId { get; set; } public int Priority { get; set; } public string ImageUrl { get; set; } public string CountryCode { get; set; } public string Description { get; set; } public List Tags { get; set; } public List Artists { get; set; } public List Tracks { get; set; } public List Categories { get; set; } public bool IsEditorialPlaylist { get; set; } public ServiceType ServiceType { get; set; } public long? Followers { get; set; } public int? BuzzCategoryId { get; set; } } }