Add merge UI

This commit is contained in:
Amelia 2025-05-07 17:41:10 +02:00
parent 29e2879153
commit 6ec7e80a43
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
13 changed files with 275 additions and 40 deletions

View file

@ -14,11 +14,12 @@ public interface IPersonService
/// </summary>
/// <param name="dst">Remaining person</param>
/// <param name="src">Merged person</param>
/// <remarks>The entities passed as arguments **must** include all relations</remarks>
/// <returns></returns>
Task MergePeopleAsync(Person dst, Person src);
/// <summary>
/// Adds the alias to the person, requires that the alias is not shared with anyone else
/// Adds the alias to the person, requires that the aliases are not shared with anyone else
/// </summary>
/// <remarks>This method does NOT commit changes</remarks>
/// <param name="person"></param>
@ -32,6 +33,7 @@ public class PersonService(IUnitOfWork unitOfWork): IPersonService
public async Task MergePeopleAsync(Person dst, Person src)
{
if (dst.Id == src.Id) return;
if (string.IsNullOrWhiteSpace(dst.Description) && !string.IsNullOrWhiteSpace(src.Description))
{
@ -68,7 +70,7 @@ public class PersonService(IUnitOfWork unitOfWork): IPersonService
dst.ChapterPeople.Add(new ChapterPeople
{
Role = chapter.Role,
Chapter = chapter.Chapter,
ChapterId = chapter.ChapterId,
Person = dst,
KavitaPlusConnection = chapter.KavitaPlusConnection,
OrderWeight = chapter.OrderWeight,
@ -79,6 +81,7 @@ public class PersonService(IUnitOfWork unitOfWork): IPersonService
{
dst.SeriesMetadataPeople.Add(new SeriesMetadataPeople
{
SeriesMetadataId = series.SeriesMetadataId,
Role = series.Role,
Person = dst,
KavitaPlusConnection = series.KavitaPlusConnection,
@ -92,6 +95,11 @@ public class PersonService(IUnitOfWork unitOfWork): IPersonService
NormalizedAlias = src.NormalizedName,
});
foreach (var alias in src.Aliases)
{
dst.Aliases.Add(alias);
}
unitOfWork.PersonRepository.Remove(src);
unitOfWork.PersonRepository.Update(dst);
await unitOfWork.CommitAsync();