v v20190511.1 beta

This commit is contained in:
Steven Hildreth 2019-05-11 12:32:25 -05:00
parent 0793dfb212
commit 7af2ae8d71
5 changed files with 47 additions and 4 deletions

View file

@ -6,11 +6,14 @@ using Roadie.Library.Models.Users;
using Roadie.Library.Utility; using Roadie.Library.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text; using System.Text;
namespace Roadie.Library.Models.Releases namespace Roadie.Library.Models.Releases
{ {
[Serializable] [Serializable]
[DebuggerDisplay("DatabaseId [{ DatabaseId }] Name [{ ReleaseName }] IsValid [{ IsValid }]")]
public class ReleaseList : EntityInfoModelBase public class ReleaseList : EntityInfoModelBase
{ {
public DataToken Release { get; set; } public DataToken Release { get; set; }
@ -21,6 +24,16 @@ namespace Roadie.Library.Models.Releases
public short? Rating { get; set; } public short? Rating { get; set; }
public decimal? Rank { get; set; } public decimal? Rank { get; set; }
[JsonIgnore]
[AdaptIgnore]
public string ReleaseName
{
get
{
return this.Release?.Text;
}
}
public string ReleaseDate public string ReleaseDate
{ {
get get
@ -67,7 +80,14 @@ namespace Roadie.Library.Models.Releases
{ {
get get
{ {
return this.Id != Guid.Empty; var shouldBeMediaCount = this.MediaCount ?? 0;
var hasMediaCount = this.Media == null || !this.Media.Any() ? 0 : this.Media.Count();
var artistName = this.Artist?.Text;
var releaseName = this.Release?.Text;
return this.Id != Guid.Empty &&
shouldBeMediaCount == hasMediaCount &&
!string.IsNullOrEmpty(artistName) &&
!string.IsNullOrEmpty(releaseName);
} }
} }

View file

@ -1,5 +1,7 @@
using System; using Newtonsoft.Json;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
namespace Roadie.Library.Models.Releases namespace Roadie.Library.Models.Releases

View file

@ -12,9 +12,27 @@ using System.Text;
namespace Roadie.Library.Models namespace Roadie.Library.Models
{ {
[Serializable] [Serializable]
[DebuggerDisplay("Trackid [{ Track.Value }], Track Name [{ Track.Text }}")] [DebuggerDisplay("Trackid [{ TrackId }], Track Name [{ TrackName }}")]
public class TrackList : EntityInfoModelBase public class TrackList : EntityInfoModelBase
{ {
[JsonIgnore]
public string TrackId
{
get
{
return this.Track?.Value;
}
}
[JsonIgnore]
public string TrackName
{
get
{
return this.Track?.Text;
}
}
public int? MediaNumber { get; set; } public int? MediaNumber { get; set; }
public int? TrackNumber { get; set; } public int? TrackNumber { get; set; }
public DataToken Track { get; set; } public DataToken Track { get; set; }

View file

@ -430,6 +430,8 @@ namespace Roadie.Api.Services
release.Media = this.DbContext.ReleaseMedias release.Media = this.DbContext.ReleaseMedias
.Include(x => x.Tracks) .Include(x => x.Tracks)
.Where(x => x.ReleaseId == release.DatabaseId) .Where(x => x.ReleaseId == release.DatabaseId)
.ToArray()
.AsQueryable()
.ProjectToType<ReleaseMediaList>() .ProjectToType<ReleaseMediaList>()
.OrderBy(x => x.MediaNumber) .OrderBy(x => x.MediaNumber)
.ToArray(); .ToArray();
@ -442,7 +444,7 @@ namespace Roadie.Api.Services
select new { trackId = t.RoadieId, ut }).ToArray(); select new { trackId = t.RoadieId, ut }).ToArray();
foreach (var userRatingForRelease in userRatingsForRelease) foreach (var userRatingForRelease in userRatingsForRelease)
{ {
var mediaTrack = release.Media.SelectMany(x => x.Tracks).FirstOrDefault(x => x.Id == userRatingForRelease.trackId); var mediaTrack = release.Media?.SelectMany(x => x.Tracks).FirstOrDefault(x => x.Id == userRatingForRelease.trackId);
if (mediaTrack != null) if (mediaTrack != null)
{ {
mediaTrack.UserRating = new UserTrack mediaTrack.UserRating = new UserTrack

View file

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Roadie.Api.Services; using Roadie.Api.Services;
using Roadie.Library.Caching; using Roadie.Library.Caching;
using Roadie.Library.Data; using Roadie.Library.Data;