This commit is contained in:
Steven Hildreth 2019-01-08 16:40:06 -06:00
parent b09aa752a6
commit c158228a04
9 changed files with 345 additions and 0 deletions

View file

@ -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<ReleaseInCollection> Collections { get; set; }
[MaxLength(50)]
public string DiscogsId { get; set; }
public IEnumerable<DataToken> Genres { get; set; }
public bool? IsVirtual { get; set; }
[MaxLength(100)]
public string ITunesId { get; set; }
public List<ReleaseLabel> 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<ReleaseMediaList> Medias { get; set; }
[MaxLength(100)]
public string MusicBrainzId { get; set; }
public IEnumerable<PlaylistList> 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<Image> Images { get; set; }
public UserRelease UserRating { get; set; }
public Image MediumThumbnail { get; set; }
}
}

View file

@ -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; }
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}
}

View file

@ -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<ReleaseMediaList> 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;
}
}
/// <summary>
/// This is populated on a request to get the list of releases for a collection.
/// </summary>
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
};
}
}
}

View file

@ -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
{
/// <summary>
/// This is used to perform .FromSql() statements and get results from SQL query
/// </summary>
[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; }
}
}

View file

@ -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<TrackList> Tracks { get; set; }
}
}

View file

@ -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<TrackList> Tracks { get; set; }
}
}

View file

@ -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; }
}
}