Write out the code needed to pass the unit tests (no UI)

This commit is contained in:
Amelia 2025-05-04 23:32:46 +02:00
parent 96d130d0b5
commit 5ece8503ff
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
12 changed files with 3908 additions and 40 deletions

View file

@ -20,6 +20,68 @@ public class PersonService(IUnitOfWork unitOfWork): IPersonService
public async Task MergePeopleAsync(Person dst, Person src)
{
throw new System.NotImplementedException();
if (string.IsNullOrWhiteSpace(dst.Description) && !string.IsNullOrWhiteSpace(src.Description))
{
dst.Description = src.Description;
}
if (dst.MalId == 0 && src.MalId != 0)
{
dst.MalId = src.MalId;
}
if (dst.AniListId == 0 && src.AniListId != 0)
{
dst.AniListId = src.AniListId;
}
if (dst.HardcoverId == null && src.HardcoverId != null)
{
dst.HardcoverId = src.HardcoverId;
}
if (dst.Asin == null && src.Asin != null)
{
dst.Asin = src.Asin;
}
if (dst.CoverImage == null && src.CoverImage != null)
{
dst.CoverImage = src.CoverImage;
}
foreach (var chapter in src.ChapterPeople)
{
dst.ChapterPeople.Add(new ChapterPeople
{
Role = chapter.Role,
Chapter = chapter.Chapter,
Person = dst,
KavitaPlusConnection = chapter.KavitaPlusConnection,
OrderWeight = chapter.OrderWeight,
});
}
foreach (var series in src.SeriesMetadataPeople)
{
dst.SeriesMetadataPeople.Add(new SeriesMetadataPeople
{
Role = series.Role,
Person = dst,
KavitaPlusConnection = series.KavitaPlusConnection,
OrderWeight = series.OrderWeight,
});
}
dst.Aliases.Add(new PersonAlias
{
Alias = src.Name,
NormalizedAlias = src.NormalizedName,
});
unitOfWork.PersonRepository.Remove(src);
unitOfWork.PersonRepository.Update(dst);
await unitOfWork.CommitAsync();
}
}