using System; using System.Collections.Generic; using System.Data.Common; using PetaPoco; using Sony.Filtr.Contracts.Abstractions; using Sony.Filtr.Contracts.Entities.Genre; namespace Sony.Filtr.Contracts.Entities { [Serializable] [TableName("tblEditorialPlaylist")] [PrimaryKey("intId", autoIncrement = true)] [ExplicitColumns] public class EditorialPlaylist : IEditorialPlaylist { public const string Version = "13"; public EditorialPlaylist() { Genres = new List(); Artists = new List(); Tracks = new List(); } public EditorialPlaylist(DbDataReader sqlReader) { ID = sqlReader.GetInt32(0); Name = sqlReader.GetString(1); SpotifyLink = new SpotifyLink(sqlReader.GetString(2)); Priority = sqlReader.GetInt32(3); //Subscribers = (uint)sqlReader.GetInt32(4); Active = sqlReader.GetBoolean(7); ApplicationID = sqlReader.GetInt32(8); if (!sqlReader.IsDBNull(6)) ImageFileName = sqlReader.GetString(6); if (!sqlReader.IsDBNull(10)) CountryCode = sqlReader.GetString(10); //PreviousSubscribers = (uint)sqlReader.GetInt32(12); DisplayName = sqlReader.GetString(11); if (!sqlReader.IsDBNull(13)) { SpotifyImageFileName = sqlReader.GetString(13); } if (!sqlReader.IsDBNull(15)) { BuzzCategoryId = sqlReader.GetInt32(15); } if (!sqlReader.IsDBNull(16)) { OwnerUsername = sqlReader.GetString(16); } Genres = new List(); Artists = new List(); Tracks = new List(); } [Column("intId")] public int ID { get; set; } [Column("intApplicationInstanceId")] public int ApplicationID { get; set; } [Column("strName")] public string Name { get; set; } public SpotifyLink SpotifyLink { get { if (SpotifyLinkUri != null) return new SpotifyLink(SpotifyLinkUri); return null; } set { SpotifyLinkUri = value.Uri; } } [Column("strSpotifyUri")] public string SpotifyLinkUri { get; set; } [Column("intPriority")] public int Priority { get; set; } [Column("strImageFileName")] public string ImageFileName { get; set; } [Column("blnActive")] public bool Active { get; set; } [Column("strCountryCode")] public string CountryCode { get; set; } [Column("blnThemeActive")] public bool ThemeActive { get; set; } [Column("blnSonyCreated")] public bool SonyCreated { get; set; } [Column("strDescription")] public string Description { get; set; } [Column("strBackgroundColor")] public string BackgroundColor { get; set; } [Column("strHeaderBackgroundColor")] public string HeaderBackgroundColor { get; set; } [Column("strHeaderImageUrl")] public string HeaderImageUrl { get; set; } [Column("intPriorityLevel")] public int PriorityLevel { get; set; } public IEnumerable Genres { get; set; } public IEnumerable Artists { get; set; } public IEnumerable Tracks { get; set; } public string OriginalImageUrl { get { if (string.IsNullOrWhiteSpace(ImageFileName)) return null; return string.Format("https://s3-eu-west-1.amazonaws.com/sony-editorialimages-original/{0}", ImageFileName); //TODO: Setting for s3-url? } } [Column("strSpotifyImageFileName")] public string SpotifyImageFileName { get; set; } [Column("strAccentColor")] public string AccentColor { get; set; } [Column("strTextColor")] public string TextColor { get; set; } [Column("strSpotifyDescription")] public string SpotifyDescription { get; set; } [Obsolete("Use Name instead")] [Column("strDisplayName")] public string DisplayName { get; set; } [Column("intBuzzCategoryId")] public int? BuzzCategoryId { get; set; } [Column("strOwnerUsername")] public string OwnerUsername { get; set; } } }