diff --git a/Roadie.Api.Library/Models/Releases/Release.cs b/Roadie.Api.Library/Models/Releases/Release.cs new file mode 100644 index 0000000..a29d0ea --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/Release.cs @@ -0,0 +1,85 @@ +using Newtonsoft.Json; +using Roadie.Library.Models.Playlists; +using Roadie.Library.Models.Statistics; +using Roadie.Library.Models.Users; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class Release : EntityModelBase + { + public const string DefaultIncludes = "tracks,stats,images,collections,labels,playlists,genres"; + public const string DefaultListIncludes = ""; + + [MaxLength(50)] + public string AmgId { get; set; } + + public ArtistList Artist { get; set; } + + public List Collections { get; set; } + + [MaxLength(50)] + public string DiscogsId { get; set; } + + public IEnumerable Genres { get; set; } + public bool? IsVirtual { get; set; } + + [MaxLength(100)] + public string ITunesId { get; set; } + + public List Labels { get; set; } + + [MaxLength(50)] + public string LastFMId { get; set; } + + [MaxLength(65535)] + public string LastFMSummary { get; set; } + + public string LibraryStatus { get; set; } + + public short? MediaCount { get; set; } + + public List Medias { get; set; } + + [MaxLength(100)] + public string MusicBrainzId { get; set; } + + public IEnumerable Playlists { get; set; } + + [MaxLength(65535)] + public string Profile { get; set; } + + public short? Rating { get; set; } + + [Required] + public DateTime ReleaseDate { get; set; } + + public string ReleaseType { get; set; } + + [MaxLength(100)] + public string SpotifyId { get; set; } + + public ReleaseSubmission Submission { get; set; } + + public Image Thumbnail { get; set; } + + // When populated a "data:image" base64 byte array of an image to use as new Thumbnail + public string NewThumbnailData { get; set; } + + + [MaxLength(250)] + [Required] + public string Title { get; set; } + + public short TrackCount { get; set; } + public string ReleasePlayUrl { get; set; } + public short MaxMediaNumber { get; set; } + public ReleaseStatistics Statistics { get; set; } + public IEnumerable Images { get; set; } + public UserRelease UserRating { get; set; } + public Image MediumThumbnail { get; set; } + } +} \ No newline at end of file diff --git a/Roadie.Api.Library/Models/Releases/ReleaseInCollection.cs b/Roadie.Api.Library/Models/Releases/ReleaseInCollection.cs new file mode 100644 index 0000000..e0294b0 --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseInCollection.cs @@ -0,0 +1,13 @@ +using Roadie.Library.Enums; +using Roadie.Library.Models.Collections; +using System; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseInCollection + { + public CollectionList Collection { get; set; } + public int ListNumber { get; set; } + } +} \ No newline at end of file diff --git a/Roadie.Api.Library/Models/Releases/ReleaseLabel.cs b/Roadie.Api.Library/Models/Releases/ReleaseLabel.cs new file mode 100644 index 0000000..db218dc --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseLabel.cs @@ -0,0 +1,19 @@ +using System; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseLabel : EntityModelBase + { + public string CatalogNumber { get; set; } + + public LabelList Label { get; set; } + + public ReleaseLabel() + { + this.CreatedDate = null; + this.Id = null; + this.Status = null; + } + } +} \ No newline at end of file diff --git a/Roadie.Api.Library/Models/Releases/ReleaseLabelList.cs b/Roadie.Api.Library/Models/Releases/ReleaseLabelList.cs new file mode 100644 index 0000000..34cd381 --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseLabelList.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseLabelList : EntityInfoModelBase + { + public DataToken Label { get; set; } + public string CatalogNumber { get; set; } + + [JsonIgnore] + + public DateTime? BeginDatedDateTime { get; set; } + public string BeginDate + { + get + { + return this.BeginDatedDateTime.HasValue ? this.BeginDatedDateTime.Value.ToString("s") : null; + } + } + + [JsonIgnore] + + public DateTime? EndDatedDateTime { get; set; } + public string EndDate + { + get + { + return this.EndDatedDateTime.HasValue ? this.EndDatedDateTime.Value.ToString("s") : null; + } + } + } +} diff --git a/Roadie.Api.Library/Models/Releases/ReleaseList.cs b/Roadie.Api.Library/Models/Releases/ReleaseList.cs new file mode 100644 index 0000000..5fd359b --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseList.cs @@ -0,0 +1,116 @@ +using Mapster; +using Newtonsoft.Json; +using Roadie.Library.Enums; +using Roadie.Library.Extensions; +using Roadie.Library.Models.Users; +using Roadie.Library.Utility; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseList : EntityInfoModelBase + { + public DataToken Release { get; set; } + public DataToken Artist { get; set; } + public Image ArtistThumbnail { get; set; } + public LibraryStatus? LibraryStatus { get; set; } + public IEnumerable Media { get; set; } + public short? Rating { get; set; } + + public string ReleaseDate + { + get + { + return this.ReleaseDateDateTime.HasValue ? this.ReleaseDateDateTime.Value.ToUniversalTime().ToString("yyyy-MM-dd") : null; + } + } + + [JsonIgnore] + public DateTime? ReleaseDateDateTime { get; set; } + + public string ReleasePlayUrl { get; set; } + + public string ReleaseYear + { + get + { + return this.ReleaseDateDateTime.HasValue ? this.ReleaseDateDateTime.Value.ToUniversalTime().ToString("yyyy") : null; + } + } + + public Image Thumbnail { get; set; } + public int? TrackCount { get; set; } + public int? TrackPlayedCount { get; set; } + public UserRelease UserRating { get; set; } + public Statuses? Status { get; set; } + public DataToken Genre { get; set; } + public DateTime? LastPlayed { get; set; } + public decimal? Duration { get; set; } + public string DurationTime + { + get + { + if(!this.Duration.HasValue) + { + return "--:--"; + } + return new TimeInfo(this.Duration.Value).ToFullFormattedString(); + } + } + public int? MediaCount { get; set; } + + public bool IsValid + { + get + { + return this.Id != Guid.Empty; + } + } + + /// + /// This is populated on a request to get the list of releases for a collection. + /// + public int? ListNumber { get; set; } + + public ReleaseList ShallowCopy() + { + return (ReleaseList)this.MemberwiseClone(); + } + + public static ReleaseList FromDataRelease(Data.Release release, Data.Artist artist, string baseUrl, Image artistThumbnail, Image thumbnail) + { + return new ReleaseList + { + DatabaseId = release.Id, + Id = release.RoadieId, + Artist = new DataToken + { + Value = artist.RoadieId.ToString(), + Text = artist.Name + }, + Release = new DataToken + { + Text = release.Title, + Value = release.RoadieId.ToString() + }, + ArtistThumbnail = artistThumbnail, + CreatedDate = release.CreatedDate, + Duration = release.Duration, + LastPlayed = release.LastPlayed, + LastUpdated = release.LastUpdated, + LibraryStatus = release.LibraryStatus, + MediaCount = release.MediaCount, + Rating = release.Rating, + ReleaseDateDateTime = release.ReleaseDate, + ReleasePlayUrl = $"{ baseUrl }/play/release/{ release.RoadieId}", + Status = release.Status, + Thumbnail = thumbnail, + TrackCount = release.TrackCount, + TrackPlayedCount = release.PlayedCount + }; + } + } +} diff --git a/Roadie.Api.Library/Models/Releases/ReleaseListFromSql.cs b/Roadie.Api.Library/Models/Releases/ReleaseListFromSql.cs new file mode 100644 index 0000000..153adc3 --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseListFromSql.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using Roadie.Library.Enums; + +namespace Roadie.Library.Models.Releases +{ + /// + /// This is used to perform .FromSql() statements and get results from SQL query + /// + [Serializable] + public class ReleaseListFromSql + { + public string ReleaseTitle { get; set; } + public Guid ReleaseRoadieId { get; set; } + public Guid ArtistRoadieId { get; set; } + public string ArtistName { get; set; } + public short? Rating { get; set; } + public int? Duration { get; set; } + public LibraryStatus? LibraryStatus { get; set; } + public DateTime? ReleaseDateDateTime { get; set; } + public int? TrackCount { get; set; } + public int? TrackPlayedCount { get; set; } + public DateTime? LastUpdated { get; set; } + public DateTime? LastPlayed { get; set; } + public DateTime? CreatedDate { get; set; } + } +} diff --git a/Roadie.Api.Library/Models/Releases/ReleaseMedia.cs b/Roadie.Api.Library/Models/Releases/ReleaseMedia.cs new file mode 100644 index 0000000..805d909 --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseMedia.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseMedia : EntityModelBase + { + public int MediaNumber { get; set; } + public string SubTitle { get; set; } + + [Required] + public short TrackCount { get; set; } + + public List Tracks { get; set; } + } +} \ No newline at end of file diff --git a/Roadie.Api.Library/Models/Releases/ReleaseMediaList.cs b/Roadie.Api.Library/Models/Releases/ReleaseMediaList.cs new file mode 100644 index 0000000..76575c1 --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseMediaList.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseMediaList : EntityInfoModelBase + { + public short? MediaNumber { get; set; } + public string SubTitle { get; set; } + public int? TrackCount { get; set; } + public IEnumerable Tracks { get; set; } + } +} diff --git a/Roadie.Api.Library/Models/Releases/ReleaseSubmission.cs b/Roadie.Api.Library/Models/Releases/ReleaseSubmission.cs new file mode 100644 index 0000000..8e5239f --- /dev/null +++ b/Roadie.Api.Library/Models/Releases/ReleaseSubmission.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Roadie.Library.Models.Releases +{ + [Serializable] + public class ReleaseSubmission : EntityInfoModelBase + { + public DataToken User { get; set; } + public Image UserThumbnail { get; set; } + public DateTime? SubmittedDate { get; set; } + } +}