diff --git a/RoadieApi/Controllers/AccountController.cs b/RoadieApi/Controllers/AccountController.cs index 2a78498..90fc26a 100644 --- a/RoadieApi/Controllers/AccountController.cs +++ b/RoadieApi/Controllers/AccountController.cs @@ -79,8 +79,10 @@ namespace Roadie.Api.Controllers Username = user.UserName, user.Email, user.LastLogin, - avatarUrl = avatarUrl, - Token = t + avatarUrl, + Token = t, + user.Timeformat, + user.Timezone }); } catch (Exception ex) diff --git a/RoadieApi/Services/ArtistService.cs b/RoadieApi/Services/ArtistService.cs index 5d04434..54b8040 100644 --- a/RoadieApi/Services/ArtistService.cs +++ b/RoadieApi/Services/ArtistService.cs @@ -100,6 +100,7 @@ namespace Roadie.Api.Services } var result = artist.Adapt(); result.Thumbnail = base.MakeArtistThumbnailImage(id); + result.MediumThumbnail = base.MakeThumbnailImage(id, "artist", this.Configuration.MediumImageSize.Width, this.Configuration.MediumImageSize.Height); result.Genres = artist.Genres.Select(x => new DataToken { Text = x.Genre.Name, Value = x.Genre.RoadieId.ToString() }); if (includes != null && includes.Any()) { @@ -183,25 +184,28 @@ namespace Roadie.Api.Services } if (includes.Contains("associatedartists")) { - result.AssociatedWithArtists = (from aa in this.DbContext.ArtistAssociations + var associatedWithArtists = (from aa in this.DbContext.ArtistAssociations join a in this.DbContext.Artists on aa.AssociatedArtistId equals a.Id where aa.ArtistId == artist.Id - orderby a.Name select new DataToken { Text = a.Name, - Value = a.RoadieId.ToString() + Value = a.RoadieId.ToString(), + Data = this.MakeArtistThumbnailImage(a.RoadieId).Url }).ToArray(); - result.AssociatedArtists = (from aa in this.DbContext.ArtistAssociations - join a in this.DbContext.Artists on aa.ArtistId equals a.Id - where aa.AssociatedArtistId == artist.Id - orderby a.Name - select new DataToken - { - Text = a.Name, - Value = a.RoadieId.ToString() - }).ToArray(); + var associatedArtists = (from aa in this.DbContext.ArtistAssociations + join a in this.DbContext.Artists on aa.ArtistId equals a.Id + where aa.AssociatedArtistId == artist.Id + select new DataToken + { + Text = a.Name, + Value = a.RoadieId.ToString(), + Data = this.MakeArtistThumbnailImage(a.RoadieId).Url + }).ToArray(); + + result.AssociatedArtists = associatedArtists.Union(associatedWithArtists).OrderBy(x => x.Text); + } if (includes.Contains("collections")) { @@ -228,9 +232,13 @@ namespace Roadie.Api.Services { result.ArtistContributionReleases = (from t in this.DbContext.Tracks join rm in this.DbContext.ReleaseMedias on t.ReleaseMediaId equals rm.Id - join r in this.DbContext.Releases on rm.ReleaseId equals r.Id + join r in this.DbContext.Releases.Include(x => x.Artist) on rm.ReleaseId equals r.Id where t.ArtistId == artist.Id - select new ReleaseList + group r by r.Id into rr + select rr) + .ToArray() + .Select(rr => rr.First()) + .Select(r => new ReleaseList { Release = new DataToken { @@ -244,20 +252,17 @@ namespace Roadie.Api.Services }, ArtistThumbnail = MakeArtistThumbnailImage(r.Artist.RoadieId), Rating = r.Rating, + Duration = r.Duration, ReleasePlayUrl = $"{ this.HttpContext.BaseUrl }/play/release/{ r.RoadieId}", LibraryStatus = r.LibraryStatus ?? LibraryStatus.Incomplete, ReleaseDateDateTime = r.ReleaseDate, TrackCount = r.TrackCount, CreatedDate = r.CreatedDate, LastUpdated = r.LastUpdated, - TrackPlayedCount = (from ut in this.DbContext.UserTracks - join t in this.DbContext.Tracks on ut.TrackId equals t.Id - join rm in this.DbContext.ReleaseMedias on t.ReleaseMediaId equals rm.Id - join rl in this.DbContext.Releases on rm.ReleaseId equals rl.Id - where rl.Id == r.Id - select ut.PlayedCount ?? 0).Sum(), + TrackPlayedCount = r.PlayedCount, + LastPlayed = r.LastPlayed, Thumbnail = MakeReleaseThumbnailImage(r.RoadieId) - }).ToArray().GroupBy(x => x.Release.Value).Select(x => x.First()).OrderBy(x => x.Release.Text).ToArray(); + }).ToArray().OrderBy(x => x.Release.Text).ToArray(); result.ArtistContributionReleases = result.ArtistContributionReleases.Any() ? result.ArtistContributionReleases : null; } if (includes.Contains("labels")) diff --git a/RoadieApi/Services/ServiceBase.cs b/RoadieApi/Services/ServiceBase.cs index 7a3dc6f..fcc7e85 100644 --- a/RoadieApi/Services/ServiceBase.cs +++ b/RoadieApi/Services/ServiceBase.cs @@ -523,9 +523,9 @@ namespace Roadie.Api.Services return new Image($"{this.HttpContext.ImageBaseUrl }/{type}/{id}"); } - private Image MakeThumbnailImage(Guid id, string type) + public Image MakeThumbnailImage(Guid id, string type, int? width = null, int? height = null) { - return this.MakeImage(id, type, this.Configuration.ThumbnailImageSize.Width, this.Configuration.ThumbnailImageSize.Height); + return this.MakeImage(id, type, width ?? this.Configuration.ThumbnailImageSize.Width, height ?? this.Configuration.ThumbnailImageSize.Height); } } } \ No newline at end of file diff --git a/RoadieApi/Startup.cs b/RoadieApi/Startup.cs index 2a037be..4ac8bd5 100644 --- a/RoadieApi/Startup.cs +++ b/RoadieApi/Startup.cs @@ -75,11 +75,7 @@ namespace Roadie.Api { routes.MapHub("/playActivityHub"); }); - app.UseMvc(b => - { - b.Select().Expand().Filter().OrderBy().MaxTop(100).Count(); - b.MapODataServiceRoute("odata", "odata", GetEdmModel()); - }); + app.UseMvc(); } // This method gets called by the runtime. Use this method to add services to the container. @@ -139,7 +135,7 @@ namespace Roadie.Api settings.ConnectionString = this._configuration.GetConnectionString("RoadieDatabaseConnection"); return settings; }); - + services.AddSingleton(); services.AddSingleton(); services.AddScoped(); services.AddScoped(); @@ -188,8 +184,6 @@ namespace Roadie.Api // }); //}); - services.AddOData(); - services.AddSignalR(); services.AddMvc(options => @@ -214,13 +208,5 @@ namespace Roadie.Api }); } - private static IEdmModel GetEdmModel() - { - ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); - builder.EntitySet("Artist"); - builder.EntitySet("Label"); - builder.EntitySet("Release"); - return builder.GetEdmModel(); - } } } \ No newline at end of file diff --git a/RoadieLibrary/Data/RoadieDbContext.cs b/RoadieLibrary/Data/RoadieDbContext.cs index 2c7fe42..5feebf7 100644 --- a/RoadieLibrary/Data/RoadieDbContext.cs +++ b/RoadieLibrary/Data/RoadieDbContext.cs @@ -63,7 +63,7 @@ namespace Roadie.Library.Data .Property(e => e.LibraryStatus) .HasConversion( v => v.ToString(), - v => (LibraryStatus)Enum.Parse(typeof(LibraryStatus), v)) + v => string.IsNullOrEmpty(v) ? LibraryStatus.Incomplete : (LibraryStatus)Enum.Parse(typeof(LibraryStatus), v)) .HasDefaultValue(LibraryStatus.Incomplete); builder @@ -71,15 +71,15 @@ namespace Roadie.Library.Data .Property(e => e.CollectionType) .HasConversion( v => v.ToString(), - v => (CollectionType)Enum.Parse(typeof(CollectionType), v)) + v => string.IsNullOrEmpty(v) ? CollectionType.Unknown : (CollectionType)Enum.Parse(typeof(CollectionType), v)) .HasDefaultValue(CollectionType.Unknown); builder .Entity() .Property(e => e.BookmarkType) .HasConversion( - v => v, - v => (BookmarkType)Enum.Parse(typeof(BookmarkType), v.ToString())) + v => v.ToString(), + v => string.IsNullOrEmpty(v) ? BookmarkType.Unknown : (BookmarkType)Enum.Parse(typeof(BookmarkType), v)) .HasDefaultValue(BookmarkType.Unknown); builder.Entity() diff --git a/RoadieLibrary/Models/Artist.cs b/RoadieLibrary/Models/Artist.cs index bf6c58c..ecec37e 100644 --- a/RoadieLibrary/Models/Artist.cs +++ b/RoadieLibrary/Models/Artist.cs @@ -25,7 +25,7 @@ namespace Roadie.Library.Models public string ArtistType { get; set; } public IEnumerable AssociatedArtists { get; set; } - public IEnumerable AssociatedWithArtists { get; set; } + public string BandStatus { get; set; } [MaxLength(65535)] @@ -83,6 +83,8 @@ namespace Roadie.Library.Models public CollectionStatistics Statistics { get; set; } public Image Thumbnail { get; set; } + public Image MediumThumbnail { get; set; } + public string Tooltip { get