mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
Implemented the ability to delete a Library.
This commit is contained in:
parent
7b1714349d
commit
5e18c1bf3a
@ -146,5 +146,12 @@ namespace API.Controllers
|
||||
{
|
||||
return Ok(await _seriesRepository.GetSeriesDtoForLibraryIdAsync(libraryId));
|
||||
}
|
||||
|
||||
[Authorize(Policy = "RequireAdminRole")]
|
||||
[HttpDelete("delete")]
|
||||
public async Task<ActionResult<bool>> DeleteLibrary(int libraryId)
|
||||
{
|
||||
return Ok(await _libraryRepository.DeleteLibrary(libraryId));
|
||||
}
|
||||
}
|
||||
}
|
@ -53,6 +53,13 @@ namespace API.Data
|
||||
.SingleAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteLibrary(int libraryId)
|
||||
{
|
||||
var library = await GetLibraryForIdAsync(libraryId);
|
||||
_context.Library.Remove(library);
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LibraryDto>> GetLibrariesAsync()
|
||||
{
|
||||
return await _context.Library
|
||||
|
@ -15,5 +15,7 @@ namespace API.Interfaces
|
||||
bool SaveAll();
|
||||
Task<IEnumerable<LibraryDto>> GetLibrariesDtoForUsernameAsync(string userName);
|
||||
Task<Library> GetLibraryForNameAsync(string libraryName);
|
||||
|
||||
Task<bool> DeleteLibrary(int libraryId);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user