merge work

This commit is contained in:
Steven Hildreth 2019-01-12 15:38:31 -06:00
parent 5acad5d4b6
commit 014607515a
3 changed files with 25 additions and 5 deletions

View file

@ -165,7 +165,7 @@ namespace Roadie.Library.Factories
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
sql = "UPDATE `image` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
sql = "UPDATE `userArtist` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
sql = "UPDATE `userartist` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);
sql = "UPDATE `track` set artistId = " + artistToMergeInto.Id + " WHERE artistId = " + ArtistToMerge.Id + ";";
await this.DbContext.Database.ExecuteSqlCommandAsync(sql);

View file

@ -550,13 +550,19 @@ namespace Roadie.Api.Services
sw.Start();
var errors = new List<Exception>();
var artistToMerge = this.GetArtist(artistToMergeId);
var artistToMerge = this.DbContext.Artists
.Include(x => x.Genres)
.Include("Genres.Genre")
.FirstOrDefault(x => x.RoadieId == artistToMergeId);
if (artistToMerge == null)
{
this.Logger.LogWarning("MergeArtists Unknown Artist [{0}]", artistToMergeId);
return new OperationResult<bool>(true, string.Format("Artist Not Found [{0}]", artistToMergeId));
}
var mergeIntoArtist = this.GetArtist(artistToMergeIntoId);
var mergeIntoArtist = this.DbContext.Artists
.Include(x => x.Genres)
.Include("Genres.Genre")
.FirstOrDefault(x => x.RoadieId == artistToMergeIntoId);
if (mergeIntoArtist == null)
{
this.Logger.LogWarning("MergeArtists Unknown Artist [{0}]", artistToMergeIntoId);

View file

@ -684,13 +684,27 @@ namespace Roadie.Api.Services
sw.Start();
var errors = new List<Exception>();
var releaseToMerge = this.GetRelease(releaseToMergeId);
var releaseToMerge = this.DbContext.Releases
.Include(x => x.Artist)
.Include(x => x.Genres)
.Include("Genres.Genre")
.Include(x => x.Medias)
.Include("Medias.Tracks")
.Include("Medias.Tracks.TrackArtist")
.FirstOrDefault(x => x.RoadieId == releaseToMergeId);
if (releaseToMerge == null)
{
this.Logger.LogWarning("MergeReleases Unknown Release [{0}]", releaseToMergeId);
return new OperationResult<bool>(true, string.Format("Release Not Found [{0}]", releaseToMergeId));
}
var releaseToMergeInfo = this.GetRelease(releaseToMergeIntoId);
var releaseToMergeInfo = this.DbContext.Releases
.Include(x => x.Artist)
.Include(x => x.Genres)
.Include("Genres.Genre")
.Include(x => x.Medias)
.Include("Medias.Tracks")
.Include("Medias.Tracks.TrackArtist")
.FirstOrDefault(x => x.RoadieId == releaseToMergeIntoId);
if (releaseToMergeInfo == null)
{
this.Logger.LogWarning("MergeReleases Unknown Release [{0}]", releaseToMergeIntoId);