public CoverError(ErrorType errorType, CoverRef cover) : base(errorType) { this.cover = cover; if (errorType != ErrorType.CoverMissingParent) { throw new ArgumentOutOfRangeException(nameof(errorType), errorType, null); } switch (cover.CoverType) { case CoverType.Role: case CoverType.Artist: this.Id = cover.ActorId; this.Id = cover.ActorId; break; case CoverType.Video: case CoverType.Background: this.Id = cover.VideoId; break; default: throw new ArgumentOutOfRangeException(); } this.Id = this.Id ?? cover.Id; }
public override async Task FixAsync(DataCenter dataCenter) { var oldId = this.cover.Id; switch (this.Type) { case ErrorType.CoverMissingParent: switch (this.cover.CoverType) { case CoverType.Artist: break; case CoverType.Video: break; case CoverType.Background: break; case CoverType.Role: if (this.cover.ActorId != null) { if (this.cover.VideoId != null) { if (this.cover.SeriesId != null) { } else { var roleCol = await dataCenter.VideoRoleManager.FindAsync(this.cover.VideoId); var matchs = roleCol.Roles().Where(z => z.ActorId == this.cover.ActorId).ToArray(); if (matchs.Length != 1) return; var cover = await dataCenter.CoverManager.FindAsync((matchs[0] as ICoverParent).CoverId); if (cover != null) return; cover = await dataCenter.CoverManager.FindAsync(this.cover.Id); cover.Id = (matchs[0] as ICoverParent).CoverId; await dataCenter.CoverManager.InsertOrUpdateAsync(cover); await dataCenter.CoverManager.RemoveAsync(oldId); } } else { } } break; default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(); } }
public static Error FromCoverMissingParent(CoverRef cover) => new CoverError(ErrorType.CoverMissingParent, cover);
public override async Task FixAsync(DataCenter dataCenter) { var oldId = this.cover.Id; switch (this.Type) { case ErrorType.CoverMissingParent: switch (this.cover.CoverType) { case CoverType.Artist: break; case CoverType.Video: break; case CoverType.Background: break; case CoverType.Role: if (this.cover.ActorId != null) { if (this.cover.VideoId != null) { if (this.cover.SeriesId != null) { } else { var roleCol = await dataCenter.VideoRoleManager.FindAsync(this.cover.VideoId); var matchs = roleCol.Roles().Where(z => z.ActorId == this.cover.ActorId).ToArray(); if (matchs.Length != 1) { return; } var cover = await dataCenter.CoverManager.FindAsync((matchs[0] as ICoverParent).CoverId); if (cover != null) { return; } cover = await dataCenter.CoverManager.FindAsync(this.cover.Id); cover.Id = (matchs[0] as ICoverParent).CoverId; await dataCenter.CoverManager.InsertOrUpdateAsync(cover); await dataCenter.CoverManager.RemoveAsync(oldId); } } else { } } break; default: throw new ArgumentOutOfRangeException(); } break; default: throw new ArgumentOutOfRangeException(); } }