mirror of
https://github.com/sphildreth/roadie
synced 2024-11-22 20:23:16 +00:00
Bookmark API work
This commit is contained in:
parent
f02e28ad58
commit
884811674e
14 changed files with 250 additions and 100 deletions
|
@ -123,6 +123,19 @@ namespace Roadie.Api.Controllers
|
|||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("setArtistBookmark/{artistId}/{isBookmarked}")]
|
||||
[ProducesResponseType(200)]
|
||||
public async Task<IActionResult> SetArtistBookmark(Guid artistId, bool isBookmarked)
|
||||
{
|
||||
var result = await this.UserService.SetArtistBookmark(artistId, await this.CurrentUserModel(), isBookmarked);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
return StatusCode((int)HttpStatusCode.InternalServerError);
|
||||
}
|
||||
this.CacheManager.ClearRegion(EntityControllerBase.ControllerCacheRegionUrn);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(200)]
|
||||
|
|
|
@ -330,22 +330,9 @@ namespace Roadie.Api.Services
|
|||
join r in this.DbContext.Releases on rl.ReleaseId equals r.Id
|
||||
where r.ArtistId == artist.Id
|
||||
orderby l.SortName
|
||||
select new LabelList
|
||||
{
|
||||
Id = rl.RoadieId,
|
||||
Label = new DataToken
|
||||
{
|
||||
Text = l.Name,
|
||||
Value = l.RoadieId.ToString()
|
||||
},
|
||||
SortName = l.SortName,
|
||||
CreatedDate = l.CreatedDate,
|
||||
LastUpdated = l.LastUpdated,
|
||||
ArtistCount = l.ArtistCount,
|
||||
ReleaseCount = l.ReleaseCount,
|
||||
TrackCount = l.TrackCount,
|
||||
Thumbnail = MakeLabelThumbnailImage(l.RoadieId)
|
||||
}).ToArray().GroupBy(x => x.Label.Value).Select(x => x.First()).OrderBy(x => x.SortName).ThenBy(x => x.Label.Text).ToArray();
|
||||
select LabelList.FromDataLabel(l, this.MakeLabelThumbnailImage(l.RoadieId)))
|
||||
.ToArray()
|
||||
.GroupBy(x => x.Label.Value).Select(x => x.First()).OrderBy(x => x.SortName).ThenBy(x => x.Label.Text).ToArray();
|
||||
result.ArtistLabels = result.ArtistLabels.Any() ? result.ArtistLabels : null;
|
||||
tsw.Stop();
|
||||
timings.Add("labels", tsw.ElapsedMilliseconds);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Encoding;
|
||||
|
@ -14,6 +15,7 @@ using System.Linq;
|
|||
using System.Linq.Dynamic.Core;
|
||||
using System.Threading.Tasks;
|
||||
using data = Roadie.Library.Data;
|
||||
using models = Roadie.Library.Models;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
|
@ -70,39 +72,59 @@ namespace Roadie.Api.Services
|
|||
Text = artist.Name,
|
||||
Value = artist.RoadieId.ToString()
|
||||
};
|
||||
row.Artist = models.ArtistList.FromDataArtist(artist, this.MakeArtistThumbnailImage(artist.RoadieId));
|
||||
row.Thumbnail = this.MakeArtistThumbnailImage(artist.RoadieId);
|
||||
row.SortName = artist.SortName ?? artist.Name;
|
||||
break;
|
||||
|
||||
case BookmarkType.Release:
|
||||
var release = this.DbContext.Releases.FirstOrDefault(x => x.Id == row.BookmarkTargetId);
|
||||
var release = this.DbContext.Releases.Include(x => x.Artist).FirstOrDefault(x => x.Id == row.BookmarkTargetId);
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
Text = release.Title,
|
||||
Value = release.RoadieId.ToString()
|
||||
};
|
||||
row.Release = models.Releases.ReleaseList.FromDataRelease(release, release.Artist, this.HttpContext.BaseUrl, this.MakeArtistThumbnailImage(release.Artist.RoadieId), this.MakeReleaseThumbnailImage(release.RoadieId));
|
||||
row.Thumbnail = this.MakeReleaseThumbnailImage(release.RoadieId);
|
||||
row.SortName = release.Title;
|
||||
break;
|
||||
|
||||
case BookmarkType.Track:
|
||||
var track = this.DbContext.Tracks.FirstOrDefault(x => x.Id == row.BookmarkTargetId);
|
||||
var track = this.DbContext.Tracks
|
||||
.Include(x => x.ReleaseMedia)
|
||||
.Include(x => x.ReleaseMedia.Release)
|
||||
.Include(x => x.ReleaseMedia.Release.Artist)
|
||||
.Include(x => x.TrackArtist)
|
||||
.FirstOrDefault(x => x.Id == row.BookmarkTargetId);
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
Text = track.Title,
|
||||
Value = track.RoadieId.ToString()
|
||||
};
|
||||
row.Track = TrackList.FromDataTrack(track,
|
||||
track.ReleaseMedia.MediaNumber,
|
||||
track.ReleaseMedia.Release,
|
||||
track.ReleaseMedia.Release.Artist,
|
||||
track.TrackArtist,
|
||||
this.HttpContext.BaseUrl,
|
||||
this.MakeTrackThumbnailImage(track.RoadieId),
|
||||
this.MakeReleaseThumbnailImage(track.ReleaseMedia.Release.RoadieId),
|
||||
this.MakeArtistThumbnailImage(track.ReleaseMedia.Release.Artist.RoadieId),
|
||||
this.MakeArtistThumbnailImage(track.TrackArtist == null ? null : (Guid?)track.TrackArtist.RoadieId));
|
||||
row.Thumbnail = this.MakeTrackThumbnailImage(track.RoadieId);
|
||||
row.SortName = track.Title;
|
||||
break;
|
||||
|
||||
case BookmarkType.Playlist:
|
||||
var playlist = this.DbContext.Playlists.FirstOrDefault(x => x.Id == row.BookmarkTargetId);
|
||||
var playlist = this.DbContext.Playlists
|
||||
.Include(x => x.User)
|
||||
.FirstOrDefault(x => x.Id == row.BookmarkTargetId);
|
||||
row.Bookmark = new DataToken
|
||||
{
|
||||
Text = playlist.Name,
|
||||
Value = playlist.RoadieId.ToString()
|
||||
};
|
||||
row.Playlist = models.Playlists.PlaylistList.FromDataPlaylist(playlist, playlist.User, this.MakePlaylistThumbnailImage(playlist.RoadieId), this.MakeUserThumbnailImage(playlist.User.RoadieId));
|
||||
row.Thumbnail = this.MakePlaylistThumbnailImage(playlist.RoadieId);
|
||||
row.SortName = playlist.Name;
|
||||
break;
|
||||
|
@ -114,6 +136,9 @@ namespace Roadie.Api.Services
|
|||
Text = collection.Name,
|
||||
Value = collection.RoadieId.ToString()
|
||||
};
|
||||
row.Collection = models.Collections.CollectionList.FromDataCollection(collection, (from crc in this.DbContext.CollectionReleases
|
||||
where crc.CollectionId == collection.Id
|
||||
select crc.Id).Count(), this.MakeCollectionThumbnailImage(collection.RoadieId));
|
||||
row.Thumbnail = this.MakeCollectionThumbnailImage(collection.RoadieId);
|
||||
row.SortName = collection.SortName ?? collection.Name;
|
||||
break;
|
||||
|
@ -125,6 +150,7 @@ namespace Roadie.Api.Services
|
|||
Text = label.Name,
|
||||
Value = label.RoadieId.ToString()
|
||||
};
|
||||
row.Label = models.LabelList.FromDataLabel(label, this.MakeLabelThumbnailImage(label.RoadieId));
|
||||
row.Thumbnail = this.MakeLabelThumbnailImage(label.RoadieId);
|
||||
row.SortName = label.SortName ?? label.Name;
|
||||
break;
|
||||
|
|
|
@ -186,24 +186,9 @@ namespace Roadie.Api.Services
|
|||
}
|
||||
var result = (from c in collections
|
||||
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && c.Name.Contains(request.Filter)))
|
||||
select new CollectionList
|
||||
{
|
||||
DatabaseId = c.Id,
|
||||
Collection = new DataToken
|
||||
{
|
||||
Text = c.Name,
|
||||
Value = c.RoadieId.ToString()
|
||||
},
|
||||
Id = c.RoadieId,
|
||||
CollectionCount = c.CollectionCount,
|
||||
CollectionType = (c.CollectionType ?? CollectionType.Unknown).ToString(),
|
||||
CollectionFoundCount = (from crc in this.DbContext.CollectionReleases
|
||||
where crc.CollectionId == c.Id
|
||||
select crc.Id).Count(),
|
||||
CreatedDate = c.CreatedDate,
|
||||
LastUpdated = c.LastUpdated,
|
||||
Thumbnail = MakeCollectionThumbnailImage(c.RoadieId)
|
||||
});
|
||||
select CollectionList.FromDataCollection(c, (from crc in this.DbContext.CollectionReleases
|
||||
where crc.CollectionId == c.Id
|
||||
select crc.Id).Count(), this.MakeCollectionThumbnailImage(c.RoadieId)));
|
||||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Collection.Text", "ASC" } }) : request.OrderValue(null);
|
||||
var rowCount = result.Count();
|
||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
|
|
|
@ -15,5 +15,6 @@ namespace Roadie.Api.Services
|
|||
Task<OperationResult<short>> SetTrackRating(Guid trackId, User roadieUser, short rating);
|
||||
Task<OperationResult<bool>> SetArtistFavorite(Guid artistId, User roadieUser, bool isFavorite);
|
||||
Task<OperationResult<bool>> SetReleaseFavorite(Guid releaseId, User roadieUser, bool isFavorite);
|
||||
Task<OperationResult<bool>> SetArtistBookmark(Guid artistId, User roadieUser, bool isBookmarked);
|
||||
}
|
||||
}
|
|
@ -116,34 +116,18 @@ namespace Roadie.Api.Services
|
|||
from trackArtist in tas.DefaultIfEmpty()
|
||||
select new PlaylistTrack
|
||||
{
|
||||
ListNumber = plt.pltr.ListNumber,
|
||||
Track = new TrackList
|
||||
{
|
||||
DatabaseId = plt.t.Id,
|
||||
Id = plt.t.RoadieId,
|
||||
Track = new DataToken
|
||||
{
|
||||
Text = plt.t.Title,
|
||||
Value = plt.t.RoadieId.ToString()
|
||||
},
|
||||
Release = ReleaseList.FromDataRelease(r, releaseArtist, this.HttpContext.BaseUrl, this.MakeArtistThumbnailImage(releaseArtist.RoadieId), this.MakeReleaseThumbnailImage(r.RoadieId)),
|
||||
LastPlayed = plt.t.LastPlayed,
|
||||
Artist = ArtistList.FromDataArtist(releaseArtist, this.MakeArtistThumbnailImage(releaseArtist.RoadieId)),
|
||||
TrackArtist = trackArtist == null ? null : ArtistList.FromDataArtist(trackArtist, this.MakeArtistThumbnailImage(trackArtist.RoadieId)),
|
||||
TrackNumber = plt.t.TrackNumber,
|
||||
MediaNumber = rm.MediaNumber,
|
||||
CreatedDate = plt.t.CreatedDate,
|
||||
LastUpdated = plt.t.LastUpdated,
|
||||
Duration = plt.t.Duration,
|
||||
FileSize = plt.t.FileSize,
|
||||
ReleaseDate = r.ReleaseDate,
|
||||
PlayedCount = plt.t.PlayedCount,
|
||||
Rating = plt.t.Rating,
|
||||
Title = plt.t.Title,
|
||||
TrackPlayUrl = $"{ this.HttpContext.BaseUrl }/play/track/{ plt.t.RoadieId }.mp3",
|
||||
Thumbnail = this.MakeTrackThumbnailImage(plt.t.RoadieId)
|
||||
}
|
||||
}).ToArray();
|
||||
ListNumber = plt.pltr.ListNumber,
|
||||
Track = TrackList.FromDataTrack(plt.t,
|
||||
rm.MediaNumber,
|
||||
r,
|
||||
releaseArtist,
|
||||
trackArtist,
|
||||
this.HttpContext.BaseUrl,
|
||||
this.MakeTrackThumbnailImage(plt.t.RoadieId),
|
||||
this.MakeReleaseThumbnailImage(r.RoadieId),
|
||||
this.MakeArtistThumbnailImage(releaseArtist.RoadieId),
|
||||
this.MakeArtistThumbnailImage(trackArtist == null ? null : (Guid?)trackArtist.RoadieId))
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -196,31 +180,8 @@ namespace Roadie.Api.Services
|
|||
where (request.FilterToArtistId == null || playlistWithArtistTrackIds.Contains(pl.Id))
|
||||
where (request.FilterToReleaseId == null || playlistReleaseTrackIds.Contains(pl.Id))
|
||||
where ((roadieUser == null && pl.IsPublic) || (roadieUser != null && u.RoadieId == roadieUser.UserId || pl.IsPublic))
|
||||
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && (pl.Name != null && pl.Name.Contains(request.FilterValue))
|
||||
))
|
||||
select new PlaylistList
|
||||
{
|
||||
Playlist = new DataToken
|
||||
{
|
||||
Text = pl.Name,
|
||||
Value = pl.RoadieId.ToString()
|
||||
|
||||
},
|
||||
User = new DataToken
|
||||
{
|
||||
Text = u.UserName,
|
||||
Value = u.RoadieId.ToString()
|
||||
},
|
||||
PlaylistCount = this.DbContext.PlaylistTracks.Where(x => x.PlayListId == pl.Id).Count(),
|
||||
IsPublic = pl.IsPublic,
|
||||
Duration = pl.Duration,
|
||||
TrackCount = pl.TrackCount,
|
||||
CreatedDate = pl.CreatedDate,
|
||||
LastUpdated = pl.LastUpdated,
|
||||
UserThumbnail = MakeUserThumbnailImage(u.RoadieId),
|
||||
Id = pl.RoadieId,
|
||||
Thumbnail = MakePlaylistThumbnailImage(pl.RoadieId)
|
||||
});
|
||||
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && (pl.Name != null && pl.Name.Contains(request.FilterValue))))
|
||||
select PlaylistList.FromDataPlaylist(pl, u, this.MakePlaylistThumbnailImage(pl.RoadieId), this.MakeUserThumbnailImage(u.RoadieId)));
|
||||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Playlist.Text", "ASC" } }) : request.OrderValue(null);
|
||||
var rowCount = result.Count();
|
||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||
|
|
|
@ -222,9 +222,13 @@ namespace Roadie.Api.Services
|
|||
}, ApplicationUser.CacheRegionUrn(id.Value));
|
||||
}
|
||||
|
||||
protected Image MakeArtistThumbnailImage(Guid id)
|
||||
protected Image MakeArtistThumbnailImage(Guid? id)
|
||||
{
|
||||
return MakeThumbnailImage(id, "artist");
|
||||
if(!id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return MakeThumbnailImage(id.Value, "artist");
|
||||
}
|
||||
|
||||
protected Image MakeCollectionThumbnailImage(Guid id)
|
||||
|
|
|
@ -27,9 +27,7 @@ namespace Roadie.Api.Services
|
|||
IHttpContext httpContext,
|
||||
data.IRoadieDbContext context,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<ArtistService> logger,
|
||||
ICollectionService collectionService,
|
||||
IPlaylistService playlistService)
|
||||
ILogger<ArtistService> logger)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpContext)
|
||||
{
|
||||
}
|
||||
|
@ -204,5 +202,55 @@ namespace Roadie.Api.Services
|
|||
return await base.ToggleReleaseFavorite(releaseId, user, isFavorite);
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> SetArtistBookmark(Guid artistId, User roadieUser, bool isBookmarked)
|
||||
{
|
||||
var user = this.GetUser(roadieUser.UserId);
|
||||
if (user == null)
|
||||
{
|
||||
return new OperationResult<bool>(true, $"Invalid User [{ roadieUser }]");
|
||||
}
|
||||
var artist = this.GetArtist(artistId);
|
||||
if (artist == null)
|
||||
{
|
||||
return new OperationResult<bool>(true, $"Invalid Artist [{ artistId }]");
|
||||
}
|
||||
var bookmark = this.DbContext.Bookmarks.FirstOrDefault(x => x.BookmarkTargetId == artist.Id &&
|
||||
x.BookmarkType == Library.Enums.BookmarkType.Artist &&
|
||||
x.UserId == roadieUser.Id);
|
||||
if (isBookmarked)
|
||||
{
|
||||
// Remove bookmark
|
||||
if(bookmark != null)
|
||||
{
|
||||
this.DbContext.Bookmarks.Remove(bookmark);
|
||||
await this.DbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add bookmark
|
||||
if(bookmark == null)
|
||||
{
|
||||
this.DbContext.Bookmarks.Add(new data.Bookmark
|
||||
{
|
||||
UserId = roadieUser.Id,
|
||||
BookmarkTargetId = artist.Id,
|
||||
BookmarkType = Library.Enums.BookmarkType.Artist,
|
||||
CreatedDate = DateTime.UtcNow,
|
||||
Status = Library.Enums.Statuses.Ok
|
||||
});
|
||||
await this.DbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
this.CacheManager.ClearRegion(user.CacheRegion);
|
||||
this.CacheManager.ClearRegion(artist.CacheRegion);
|
||||
|
||||
return new OperationResult<bool>
|
||||
{
|
||||
IsSuccess = true,
|
||||
Data = true
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,10 +11,10 @@ namespace Roadie.Library.Data
|
|||
[Column("bookmarkTargetId")]
|
||||
public int BookmarkTargetId { get; set; }
|
||||
|
||||
[Column("bookmarkType")]
|
||||
public short? Type { get; set; }
|
||||
|
||||
// [Column("bookmarkType")]
|
||||
// public short? Type { get; set; }
|
||||
|
||||
[Column("bookmarkType")]
|
||||
public BookmarkType? BookmarkType { get; set; }
|
||||
|
||||
public ApplicationUser User { get; set; }
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using Newtonsoft.Json;
|
||||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Models.Collections;
|
||||
using Roadie.Library.Models.Playlists;
|
||||
using Roadie.Library.Models.Releases;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
@ -13,9 +16,22 @@ namespace Roadie.Library.Models
|
|||
public DataToken Bookmark { get; set; }
|
||||
public Image Thumbnail { get; set; }
|
||||
public BookmarkType? Type { get; set; }
|
||||
public string BookmarkType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Type.ToString();
|
||||
}
|
||||
}
|
||||
[JsonIgnore]
|
||||
public int BookmarkTargetId { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public int? Position { get; set; }
|
||||
public ArtistList Artist { get; set; }
|
||||
public ReleaseList Release { get; set; }
|
||||
public TrackList Track { get; set; }
|
||||
public PlaylistList Playlist { get; set; }
|
||||
public CollectionList Collection { get; set; }
|
||||
public LabelList Label { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,5 +27,25 @@ namespace Roadie.Library.Models.Collections
|
|||
return (int)Math.Floor((decimal)this.CollectionFoundCount / (decimal)this.CollectionCount * 100);
|
||||
}
|
||||
}
|
||||
|
||||
public static CollectionList FromDataCollection(Data.Collection collection, int foundCount, Image collectionThumbnail)
|
||||
{
|
||||
return new CollectionList
|
||||
{
|
||||
DatabaseId = collection.Id,
|
||||
Collection = new DataToken
|
||||
{
|
||||
Text = collection.Name,
|
||||
Value = collection.RoadieId.ToString()
|
||||
},
|
||||
Id = collection.RoadieId,
|
||||
CollectionCount = collection.CollectionCount,
|
||||
CollectionType = (collection.CollectionType ?? Roadie.Library.Enums.CollectionType.Unknown).ToString(),
|
||||
CollectionFoundCount = foundCount,
|
||||
CreatedDate = collection.CreatedDate,
|
||||
LastUpdated = collection.LastUpdated,
|
||||
Thumbnail = collectionThumbnail
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,5 +13,25 @@ namespace Roadie.Library.Models
|
|||
public int? ArtistCount { get; set; }
|
||||
public int? ReleaseCount { get; set; }
|
||||
public int? TrackCount { get; set; }
|
||||
|
||||
public static LabelList FromDataLabel(Data.Label label, Image labelThumbnail)
|
||||
{
|
||||
return new LabelList
|
||||
{
|
||||
Id = label.RoadieId,
|
||||
Label = new DataToken
|
||||
{
|
||||
Text = label.Name,
|
||||
Value = label.RoadieId.ToString()
|
||||
},
|
||||
SortName = label.SortName,
|
||||
CreatedDate = label.CreatedDate,
|
||||
LastUpdated = label.LastUpdated,
|
||||
ArtistCount = label.ArtistCount,
|
||||
ReleaseCount = label.ReleaseCount,
|
||||
TrackCount = label.TrackCount,
|
||||
Thumbnail = labelThumbnail
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Roadie.Library.Utility;
|
||||
using Roadie.Library.Identity;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
@ -29,5 +30,32 @@ namespace Roadie.Library.Models.Playlists
|
|||
}
|
||||
|
||||
public short TrackCount { get; set; }
|
||||
|
||||
public static PlaylistList FromDataPlaylist(Data.Playlist playlist, ApplicationUser user, Image playlistThumbnail, Image userThumbnail)
|
||||
{
|
||||
return new PlaylistList
|
||||
{
|
||||
Playlist = new DataToken
|
||||
{
|
||||
Text = playlist.Name,
|
||||
Value = playlist.RoadieId.ToString()
|
||||
|
||||
},
|
||||
User = new DataToken
|
||||
{
|
||||
Text = user.UserName,
|
||||
Value = user.RoadieId.ToString()
|
||||
},
|
||||
PlaylistCount = playlist.TrackCount,
|
||||
IsPublic = playlist.IsPublic,
|
||||
Duration = playlist.Duration,
|
||||
TrackCount = playlist.TrackCount,
|
||||
CreatedDate = playlist.CreatedDate,
|
||||
LastUpdated = playlist.LastUpdated,
|
||||
UserThumbnail = userThumbnail,
|
||||
Id = playlist.RoadieId,
|
||||
Thumbnail = playlistThumbnail
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,5 +76,46 @@ namespace Roadie.Library.Models
|
|||
}
|
||||
public int? FileSize { get; set; }
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue