2018-11-14 03:19:28 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2018-12-07 21:02:38 +00:00
|
|
|
|
using Roadie.Library.Models.Releases;
|
2018-11-14 03:19:28 +00:00
|
|
|
|
using Roadie.Library.Models.Users;
|
2018-12-11 04:41:15 +00:00
|
|
|
|
using Roadie.Library.Utility;
|
2018-11-14 03:19:28 +00:00
|
|
|
|
using System;
|
2018-11-06 03:26:46 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-11-14 03:19:28 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Runtime.Serialization;
|
2018-11-06 03:26:46 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Roadie.Library.Models
|
|
|
|
|
{
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class TrackList : EntityInfoModelBase
|
|
|
|
|
{
|
2018-11-15 00:16:25 +00:00
|
|
|
|
public int? MediaNumber { get; set; }
|
2018-11-06 03:26:46 +00:00
|
|
|
|
public int? TrackNumber { get; set; }
|
2018-11-15 00:16:25 +00:00
|
|
|
|
public DataToken Track { get; set; }
|
2018-12-07 21:02:38 +00:00
|
|
|
|
public ReleaseList Release { get; set; }
|
|
|
|
|
public ArtistList Artist { get; set; }
|
2018-12-07 04:45:09 +00:00
|
|
|
|
public ArtistList TrackArtist { get; set; }
|
2018-11-06 03:26:46 +00:00
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public int? Duration { get; set; }
|
|
|
|
|
public string DurationTime
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-12-11 04:41:15 +00:00
|
|
|
|
return this.Duration.HasValue ? new TimeInfo((decimal)this.Duration.Value).ToFullFormattedString() : "--:--";
|
2018-11-06 03:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-06 03:43:17 +00:00
|
|
|
|
public string DurationTimeShort
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2018-12-11 04:41:15 +00:00
|
|
|
|
return this.Duration.HasValue ? new TimeInfo((decimal)this.Duration.Value).ToShortFormattedString() : "--:--";
|
2018-11-06 03:43:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-08 19:47:19 +00:00
|
|
|
|
public DateTime? LastPlayed { get; set; }
|
2018-11-21 06:34:53 +00:00
|
|
|
|
public short? ReleaseRating { get; set; }
|
2018-11-06 03:26:46 +00:00
|
|
|
|
public short? Rating { get; set; }
|
2018-11-15 00:16:25 +00:00
|
|
|
|
public UserTrack UserRating { get; set; }
|
2018-11-06 03:26:46 +00:00
|
|
|
|
public int? PlayedCount { get; set; }
|
|
|
|
|
public int? FavoriteCount { get; set; }
|
2018-11-14 03:19:28 +00:00
|
|
|
|
public Image Thumbnail { get; set; }
|
2018-11-06 03:26:46 +00:00
|
|
|
|
public string TrackPlayUrl { get; set; }
|
2018-11-14 03:19:28 +00:00
|
|
|
|
|
|
|
|
|
[MaxLength(65535)]
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public string PartTitles { get; set; }
|
|
|
|
|
|
|
|
|
|
public IEnumerable<string> PartTitlesList
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(this.PartTitles))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-12-08 03:10:21 +00:00
|
|
|
|
return this.PartTitles.Split('\n');
|
2018-11-14 03:19:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-21 06:34:53 +00:00
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public DateTime? ReleaseDate { get; set; }
|
|
|
|
|
public int? Year
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if(this.ReleaseDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
return this.ReleaseDate.Value.Year;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public int? FileSize { get; set; }
|
2018-12-08 19:47:19 +00:00
|
|
|
|
|
2018-12-11 23:09:52 +00:00
|
|
|
|
|
|
|
|
|
public static TrackList FromDataTrack(Data.Track track,
|
|
|
|
|
int releaseMediaNumber,
|
|
|
|
|
Data.Release release,
|
|
|
|
|
Data.Artist artist,
|
|
|
|
|
Data.Artist trackArtist,
|
|
|
|
|
string baseUrl,
|
|
|
|
|
Image trackThumbnail,
|
|
|
|
|
Image releaseThumbnail,
|
|
|
|
|
Image artistThumbnail,
|
|
|
|
|
Image trackArtistThumbnail)
|
|
|
|
|
{
|
|
|
|
|
return new TrackList
|
|
|
|
|
{
|
|
|
|
|
DatabaseId = track.Id,
|
|
|
|
|
Id = track.RoadieId,
|
|
|
|
|
Track = new DataToken
|
|
|
|
|
{
|
|
|
|
|
Text = track.Title,
|
|
|
|
|
Value = track.RoadieId.ToString()
|
|
|
|
|
},
|
|
|
|
|
Release = ReleaseList.FromDataRelease(release, artist, baseUrl, artistThumbnail, releaseThumbnail),
|
|
|
|
|
LastPlayed = track.LastPlayed,
|
|
|
|
|
Artist = ArtistList.FromDataArtist(artist, artistThumbnail),
|
|
|
|
|
TrackArtist = trackArtist == null ? null : ArtistList.FromDataArtist(trackArtist, trackArtistThumbnail),
|
|
|
|
|
TrackNumber = track.TrackNumber,
|
|
|
|
|
MediaNumber = releaseMediaNumber,
|
|
|
|
|
CreatedDate = track.CreatedDate,
|
|
|
|
|
LastUpdated = track.LastUpdated,
|
|
|
|
|
Duration = track.Duration,
|
|
|
|
|
FileSize = track.FileSize,
|
|
|
|
|
ReleaseDate = release.ReleaseDate,
|
|
|
|
|
PlayedCount = track.PlayedCount,
|
|
|
|
|
Rating = track.Rating,
|
|
|
|
|
Title = track.Title,
|
|
|
|
|
TrackPlayUrl = $"{ baseUrl }/play/track/{ track.RoadieId }.mp3",
|
|
|
|
|
Thumbnail = trackThumbnail
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-06 03:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|