Skip to content

Commit

Permalink
All Chapter update api code is converted to the new scanner code. Upd…
Browse files Browse the repository at this point in the history
…ate Series is next.
  • Loading branch information
majora2007 committed Oct 13, 2024
1 parent 724fc5e commit e55b0bd
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions API/Controllers/ChapterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,29 +136,18 @@ public async Task<ActionResult> UpdateChapterMetadata(UpdateChapterDto dto)


#region Genres
if (dto.Genres != null &&
dto.Genres.Count != 0)
if (dto.Genres is {Count: > 0})
{
var allGenres = (await _unitOfWork.GenreRepository.GetAllGenresByNamesAsync(dto.Genres.Select(t => Parser.Normalize(t.Title)))).ToList();
chapter.Genres ??= new List<Genre>();
GenreHelper.UpdateGenreList(dto.Genres, chapter, allGenres, genre =>
{
chapter.Genres.Add(genre);
}, () => chapter.GenresLocked = true);
await GenreHelper.UpdateChapterGenres(chapter, dto.Genres.Select(t => t.Title), _unitOfWork);
}
#endregion

#region Tags
if (dto.Tags is {Count: > 0})
{
var allTags = (await _unitOfWork.TagRepository
.GetAllTagsByNameAsync(dto.Tags.Select(t => Parser.Normalize(t.Title))))
.ToList();
chapter.Tags ??= new List<Tag>();
TagHelper.UpdateTagList(dto.Tags, chapter, allTags, tag =>
{
chapter.Tags.Add(tag);
}, () => chapter.TagsLocked = true);
await TagHelper.UpdateChapterTags(chapter, dto.Tags.Select(t => t.Title), _unitOfWork);
}
#endregion

Expand Down

0 comments on commit e55b0bd

Please sign in to comment.