Implemented ability to delete a series. Refactored some operations to remove unneeded parameters.
This commit is contained in:
parent
83076f02ad
commit
56e8a0059e
9 changed files with 50 additions and 16 deletions
|
|
@ -38,10 +38,12 @@ namespace API.Data
|
|||
|
||||
public async Task<IEnumerable<LibraryDto>> GetLibrariesDtoForUsernameAsync(string userName)
|
||||
{
|
||||
// TODO: Speed this query up
|
||||
return await _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.Where(library => library.AppUsers.Any(x => x.UserName == userName))
|
||||
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
.ProjectTo<LibraryDto>(_mapper.ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Library> GetLibraryForNameAsync(string libraryName)
|
||||
|
|
|
|||
|
|
@ -104,5 +104,13 @@ namespace API.Data
|
|||
.Where(v => seriesIds.Contains(v.SeriesId))
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteSeriesAsync(int seriesId)
|
||||
{
|
||||
var series = await _context.Series.Where(s => s.Id == seriesId).SingleOrDefaultAsync();
|
||||
_context.Series.Remove(series);
|
||||
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue