public async Task <ActionResult <bool> > DeleteSeries(int seriesId) { var username = User.GetUsername(); var chapterIds = (await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(new [] { seriesId })); _logger.LogInformation("Series {SeriesId} is being deleted by {UserName}", seriesId, username); var result = await _unitOfWork.SeriesRepository.DeleteSeriesAsync(seriesId); if (result) { _taskScheduler.CleanupChapters(chapterIds); } return(Ok(result)); }
public async Task <ActionResult <bool> > DeleteLibrary(int libraryId) { var username = User.GetUsername(); _logger.LogInformation("Library {LibraryId} is being deleted by {UserName}", libraryId, username); var series = await _unitOfWork.SeriesRepository.GetSeriesForLibraryIdAsync(libraryId); var chapterIds = await _unitOfWork.SeriesRepository.GetChapterIdsForSeriesAsync(series.Select(x => x.Id).ToArray()); var result = await _unitOfWork.LibraryRepository.DeleteLibrary(libraryId); if (result && chapterIds.Any()) { _taskScheduler.CleanupChapters(chapterIds); } return(Ok(result)); }