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 System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace Roadie.Library.Models.Releases
{
[Serializable]
[DebuggerDisplay("DatabaseId [{ DatabaseId }] Name [{ ReleaseName }] IsValid [{ IsValid }]")]
public class ReleaseList : EntityInfoModelBase
{
public DataToken Release { get; set; }
@ -21,6 +24,16 @@ namespace Roadie.Library.Models.Releases
public short? Rating { get; set; }
public decimal? Rank { get; set; }
[JsonIgnore]
[AdaptIgnore]
public string ReleaseName
{
get
{
return this.Release?.Text;
}
}
public string ReleaseDate
{
get
@ -67,7 +80,14 @@ namespace Roadie.Library.Models.Releases
{
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.Linq;
using System.Text;
namespace Roadie.Library.Models.Releases

View file

@ -12,9 +12,27 @@ using System.Text;
namespace Roadie.Library.Models
{
[Serializable]
[DebuggerDisplay("Trackid [{ Track.Value }], Track Name [{ Track.Text }}")]
[DebuggerDisplay("Trackid [{ TrackId }], Track Name [{ TrackName }}")]
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? TrackNumber { get; set; }
public DataToken Track { get; set; }

View file

@ -430,6 +430,8 @@ namespace Roadie.Api.Services
release.Media = this.DbContext.ReleaseMedias
.Include(x => x.Tracks)
.Where(x => x.ReleaseId == release.DatabaseId)
.ToArray()
.AsQueryable()
.ProjectToType<ReleaseMediaList>()
.OrderBy(x => x.MediaNumber)
.ToArray();
@ -442,7 +444,7 @@ namespace Roadie.Api.Services
select new { trackId = t.RoadieId, ut }).ToArray();
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)
{
mediaTrack.UserRating = new UserTrack

View file

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