mirror of
https://github.com/sphildreth/roadie
synced 2024-11-23 04:33: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);
|
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]
|
[HttpGet]
|
||||||
[ProducesResponseType(200)]
|
[ProducesResponseType(200)]
|
||||||
|
|
|
@ -330,22 +330,9 @@ namespace Roadie.Api.Services
|
||||||
join r in this.DbContext.Releases on rl.ReleaseId equals r.Id
|
join r in this.DbContext.Releases on rl.ReleaseId equals r.Id
|
||||||
where r.ArtistId == artist.Id
|
where r.ArtistId == artist.Id
|
||||||
orderby l.SortName
|
orderby l.SortName
|
||||||
select new LabelList
|
select LabelList.FromDataLabel(l, this.MakeLabelThumbnailImage(l.RoadieId)))
|
||||||
{
|
.ToArray()
|
||||||
Id = rl.RoadieId,
|
.GroupBy(x => x.Label.Value).Select(x => x.First()).OrderBy(x => x.SortName).ThenBy(x => x.Label.Text).ToArray();
|
||||||
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();
|
|
||||||
result.ArtistLabels = result.ArtistLabels.Any() ? result.ArtistLabels : null;
|
result.ArtistLabels = result.ArtistLabels.Any() ? result.ArtistLabels : null;
|
||||||
tsw.Stop();
|
tsw.Stop();
|
||||||
timings.Add("labels", tsw.ElapsedMilliseconds);
|
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.Caching;
|
||||||
using Roadie.Library.Configuration;
|
using Roadie.Library.Configuration;
|
||||||
using Roadie.Library.Encoding;
|
using Roadie.Library.Encoding;
|
||||||
|
@ -14,6 +15,7 @@ using System.Linq;
|
||||||
using System.Linq.Dynamic.Core;
|
using System.Linq.Dynamic.Core;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using data = Roadie.Library.Data;
|
using data = Roadie.Library.Data;
|
||||||
|
using models = Roadie.Library.Models;
|
||||||
|
|
||||||
namespace Roadie.Api.Services
|
namespace Roadie.Api.Services
|
||||||
{
|
{
|
||||||
|
@ -70,39 +72,59 @@ namespace Roadie.Api.Services
|
||||||
Text = artist.Name,
|
Text = artist.Name,
|
||||||
Value = artist.RoadieId.ToString()
|
Value = artist.RoadieId.ToString()
|
||||||
};
|
};
|
||||||
|
row.Artist = models.ArtistList.FromDataArtist(artist, this.MakeArtistThumbnailImage(artist.RoadieId));
|
||||||
row.Thumbnail = this.MakeArtistThumbnailImage(artist.RoadieId);
|
row.Thumbnail = this.MakeArtistThumbnailImage(artist.RoadieId);
|
||||||
row.SortName = artist.SortName ?? artist.Name;
|
row.SortName = artist.SortName ?? artist.Name;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BookmarkType.Release:
|
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
|
row.Bookmark = new DataToken
|
||||||
{
|
{
|
||||||
Text = release.Title,
|
Text = release.Title,
|
||||||
Value = release.RoadieId.ToString()
|
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.Thumbnail = this.MakeReleaseThumbnailImage(release.RoadieId);
|
||||||
row.SortName = release.Title;
|
row.SortName = release.Title;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BookmarkType.Track:
|
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
|
row.Bookmark = new DataToken
|
||||||
{
|
{
|
||||||
Text = track.Title,
|
Text = track.Title,
|
||||||
Value = track.RoadieId.ToString()
|
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.Thumbnail = this.MakeTrackThumbnailImage(track.RoadieId);
|
||||||
row.SortName = track.Title;
|
row.SortName = track.Title;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BookmarkType.Playlist:
|
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
|
row.Bookmark = new DataToken
|
||||||
{
|
{
|
||||||
Text = playlist.Name,
|
Text = playlist.Name,
|
||||||
Value = playlist.RoadieId.ToString()
|
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.Thumbnail = this.MakePlaylistThumbnailImage(playlist.RoadieId);
|
||||||
row.SortName = playlist.Name;
|
row.SortName = playlist.Name;
|
||||||
break;
|
break;
|
||||||
|
@ -114,6 +136,9 @@ namespace Roadie.Api.Services
|
||||||
Text = collection.Name,
|
Text = collection.Name,
|
||||||
Value = collection.RoadieId.ToString()
|
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.Thumbnail = this.MakeCollectionThumbnailImage(collection.RoadieId);
|
||||||
row.SortName = collection.SortName ?? collection.Name;
|
row.SortName = collection.SortName ?? collection.Name;
|
||||||
break;
|
break;
|
||||||
|
@ -125,6 +150,7 @@ namespace Roadie.Api.Services
|
||||||
Text = label.Name,
|
Text = label.Name,
|
||||||
Value = label.RoadieId.ToString()
|
Value = label.RoadieId.ToString()
|
||||||
};
|
};
|
||||||
|
row.Label = models.LabelList.FromDataLabel(label, this.MakeLabelThumbnailImage(label.RoadieId));
|
||||||
row.Thumbnail = this.MakeLabelThumbnailImage(label.RoadieId);
|
row.Thumbnail = this.MakeLabelThumbnailImage(label.RoadieId);
|
||||||
row.SortName = label.SortName ?? label.Name;
|
row.SortName = label.SortName ?? label.Name;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -186,24 +186,9 @@ namespace Roadie.Api.Services
|
||||||
}
|
}
|
||||||
var result = (from c in collections
|
var result = (from c in collections
|
||||||
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && c.Name.Contains(request.Filter)))
|
where (request.FilterValue.Length == 0 || (request.FilterValue.Length > 0 && c.Name.Contains(request.Filter)))
|
||||||
select new CollectionList
|
select CollectionList.FromDataCollection(c, (from crc in this.DbContext.CollectionReleases
|
||||||
{
|
where crc.CollectionId == c.Id
|
||||||
DatabaseId = c.Id,
|
select crc.Id).Count(), this.MakeCollectionThumbnailImage(c.RoadieId)));
|
||||||
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)
|
|
||||||
});
|
|
||||||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Collection.Text", "ASC" } }) : request.OrderValue(null);
|
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Collection.Text", "ASC" } }) : request.OrderValue(null);
|
||||||
var rowCount = result.Count();
|
var rowCount = result.Count();
|
||||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
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<short>> SetTrackRating(Guid trackId, User roadieUser, short rating);
|
||||||
Task<OperationResult<bool>> SetArtistFavorite(Guid artistId, User roadieUser, bool isFavorite);
|
Task<OperationResult<bool>> SetArtistFavorite(Guid artistId, User roadieUser, bool isFavorite);
|
||||||
Task<OperationResult<bool>> SetReleaseFavorite(Guid releaseId, 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()
|
from trackArtist in tas.DefaultIfEmpty()
|
||||||
select new PlaylistTrack
|
select new PlaylistTrack
|
||||||
{
|
{
|
||||||
ListNumber = plt.pltr.ListNumber,
|
ListNumber = plt.pltr.ListNumber,
|
||||||
Track = new TrackList
|
Track = TrackList.FromDataTrack(plt.t,
|
||||||
{
|
rm.MediaNumber,
|
||||||
DatabaseId = plt.t.Id,
|
r,
|
||||||
Id = plt.t.RoadieId,
|
releaseArtist,
|
||||||
Track = new DataToken
|
trackArtist,
|
||||||
{
|
this.HttpContext.BaseUrl,
|
||||||
Text = plt.t.Title,
|
this.MakeTrackThumbnailImage(plt.t.RoadieId),
|
||||||
Value = plt.t.RoadieId.ToString()
|
this.MakeReleaseThumbnailImage(r.RoadieId),
|
||||||
},
|
this.MakeArtistThumbnailImage(releaseArtist.RoadieId),
|
||||||
Release = ReleaseList.FromDataRelease(r, releaseArtist, this.HttpContext.BaseUrl, this.MakeArtistThumbnailImage(releaseArtist.RoadieId), this.MakeReleaseThumbnailImage(r.RoadieId)),
|
this.MakeArtistThumbnailImage(trackArtist == null ? null : (Guid?)trackArtist.RoadieId))
|
||||||
LastPlayed = plt.t.LastPlayed,
|
}).ToArray();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -196,31 +180,8 @@ namespace Roadie.Api.Services
|
||||||
where (request.FilterToArtistId == null || playlistWithArtistTrackIds.Contains(pl.Id))
|
where (request.FilterToArtistId == null || playlistWithArtistTrackIds.Contains(pl.Id))
|
||||||
where (request.FilterToReleaseId == null || playlistReleaseTrackIds.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 ((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))
|
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)));
|
||||||
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)
|
|
||||||
});
|
|
||||||
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Playlist.Text", "ASC" } }) : request.OrderValue(null);
|
var sortBy = string.IsNullOrEmpty(request.Sort) ? request.OrderValue(new Dictionary<string, string> { { "Playlist.Text", "ASC" } }) : request.OrderValue(null);
|
||||||
var rowCount = result.Count();
|
var rowCount = result.Count();
|
||||||
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
var rows = result.OrderBy(sortBy).Skip(request.SkipValue).Take(request.LimitValue).ToArray();
|
||||||
|
|
|
@ -222,9 +222,13 @@ namespace Roadie.Api.Services
|
||||||
}, ApplicationUser.CacheRegionUrn(id.Value));
|
}, 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)
|
protected Image MakeCollectionThumbnailImage(Guid id)
|
||||||
|
|
|
@ -27,9 +27,7 @@ namespace Roadie.Api.Services
|
||||||
IHttpContext httpContext,
|
IHttpContext httpContext,
|
||||||
data.IRoadieDbContext context,
|
data.IRoadieDbContext context,
|
||||||
ICacheManager cacheManager,
|
ICacheManager cacheManager,
|
||||||
ILogger<ArtistService> logger,
|
ILogger<ArtistService> logger)
|
||||||
ICollectionService collectionService,
|
|
||||||
IPlaylistService playlistService)
|
|
||||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpContext)
|
: base(configuration, httpEncoder, context, cacheManager, logger, httpContext)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -204,5 +202,55 @@ namespace Roadie.Api.Services
|
||||||
return await base.ToggleReleaseFavorite(releaseId, user, isFavorite);
|
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")]
|
[Column("bookmarkTargetId")]
|
||||||
public int BookmarkTargetId { get; set; }
|
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 BookmarkType? BookmarkType { get; set; }
|
||||||
|
|
||||||
public ApplicationUser User { get; set; }
|
public ApplicationUser User { get; set; }
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Roadie.Library.Enums;
|
using Roadie.Library.Enums;
|
||||||
|
using Roadie.Library.Models.Collections;
|
||||||
|
using Roadie.Library.Models.Playlists;
|
||||||
|
using Roadie.Library.Models.Releases;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -13,9 +16,22 @@ namespace Roadie.Library.Models
|
||||||
public DataToken Bookmark { get; set; }
|
public DataToken Bookmark { get; set; }
|
||||||
public Image Thumbnail { get; set; }
|
public Image Thumbnail { get; set; }
|
||||||
public BookmarkType? Type { get; set; }
|
public BookmarkType? Type { get; set; }
|
||||||
|
public string BookmarkType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.Type.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int BookmarkTargetId { get; set; }
|
public int BookmarkTargetId { get; set; }
|
||||||
public string Comment { get; set; }
|
public string Comment { get; set; }
|
||||||
public int? Position { 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);
|
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? ArtistCount { get; set; }
|
||||||
public int? ReleaseCount { get; set; }
|
public int? ReleaseCount { get; set; }
|
||||||
public int? TrackCount { 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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -29,5 +30,32 @@ namespace Roadie.Library.Models.Playlists
|
||||||
}
|
}
|
||||||
|
|
||||||
public short TrackCount { get; set; }
|
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 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