/// <summary>
        /// Creates a new MediaItem object using the data in a data row
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="row">DataRow containing the data for the media item</param>
        /// <returns>MediaItem object with properties loaded from the database</returns>
        internal static MediaItem FromDataRow(SqlConnection conn, sp.DataRow row)
        {
            MediaItemTypeEnum type = (MediaItemTypeEnum)Convert.ToInt16(row["Type"]);
            MediaItem         mediaItem;

            switch (type)
            {
            case MediaItemTypeEnum.Video:
                mediaItem = Video.FromDataRow(row);
                break;

            case MediaItemTypeEnum.Song:
                mediaItem = Song.FromDataRow(row);
                break;

            default:
                throw new UnknownEnumValueException(type);
            }

            mediaItem.id           = (Int64)row["Id"];
            mediaItem.Genre        = (String)row["Genre"];
            mediaItem.name         = (String)row["Name"];
            mediaItem.isHidden     = (Boolean)row["IsHidden"];
            mediaItem.dateCreated  = (DateTime)row["DateCreated"];
            mediaItem.dateModified = (DateTime)row["DateModified"];
            mediaItem.UserName     = (String)row["UserName"];

            mediaItem.playHistory = Data.MediaItem.GetMediaItemPlayHistoryById(conn, mediaItem.id, mediaItem.Type);
            mediaItem.parts       = MediaItemPart.GetMediaItemPartsById(conn, mediaItem.Id, mediaItem.Type);
            mediaItem.tags        = new ObservableCollection <IntelligentString>(Data.MediaItem.GetMediaItemTagsById(conn, mediaItem.id, mediaItem.Type));

            mediaItem.IsInDatabase = true;

            return(mediaItem);
        }
Example #2
0
        public int CompareTo(object obj)
        {
            if (!(obj is MediaItemPart))
            {
                throw new ArgumentException("Both items being compared must be MediaItemPart objects");
            }

            MediaItemPart part = obj as MediaItemPart;

            return(Index.CompareTo(part.Index));
        }