Fixed grant-access api and new library to properly update the db. Somehow the old way of updating db no longer works.
This commit is contained in:
parent
80283bcd49
commit
295e62d773
7 changed files with 64 additions and 61 deletions
|
@ -36,6 +36,13 @@ namespace API.Data
|
|||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Library>> GetLibrariesAsync()
|
||||
{
|
||||
return await _context.Library
|
||||
.Include(l => l.AppUsers)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Library> GetLibraryForNameAsync(string libraryName)
|
||||
{
|
||||
|
|
|
@ -32,27 +32,9 @@ namespace API.Data
|
|||
|
||||
public void Delete(AppUser user)
|
||||
{
|
||||
// TODO: Check how to implement for _userMangaer
|
||||
_context.AppUser.Remove(user);
|
||||
}
|
||||
|
||||
public async Task<bool> SaveAllAsync()
|
||||
{
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<AppUser>> GetUsersAsync()
|
||||
{
|
||||
return await _userManager.Users.ToListAsync();
|
||||
//return await _context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<AppUser> GetUserByIdAsync(int id)
|
||||
{
|
||||
// TODO: How to use userManager
|
||||
return await _context.AppUser.FindAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an AppUser by username. Returns back Progress information.
|
||||
/// </summary>
|
||||
|
@ -60,7 +42,7 @@ namespace API.Data
|
|||
/// <returns></returns>
|
||||
public async Task<AppUser> GetUserByUsernameAsync(string username)
|
||||
{
|
||||
return await _userManager.Users
|
||||
return await _context.Users
|
||||
.Include(u => u.Progresses)
|
||||
.SingleOrDefaultAsync(x => x.UserName == username);
|
||||
}
|
||||
|
@ -72,7 +54,7 @@ namespace API.Data
|
|||
|
||||
public async Task<IEnumerable<MemberDto>> GetMembersAsync()
|
||||
{
|
||||
return await _userManager.Users
|
||||
return await _context.Users
|
||||
.Include(x => x.Libraries)
|
||||
.Include(r => r.UserRoles)
|
||||
.ThenInclude(r => r.Role)
|
||||
|
@ -92,21 +74,16 @@ namespace API.Data
|
|||
Folders = l.Folders.Select(x => x.Path).ToList()
|
||||
}).ToList()
|
||||
})
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<MemberDto> GetMemberAsync(string username)
|
||||
{
|
||||
return await _userManager.Users.Where(x => x.UserName == username)
|
||||
.Include(x => x.Libraries)
|
||||
.ProjectTo<MemberDto>(_mapper.ConfigurationProvider)
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
public void UpdateReadingProgressAsync(int volumeId, int pageNum)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// public async Task<MemberDto> GetMemberAsync(string username)
|
||||
// {
|
||||
// return await _context.Users.Where(x => x.UserName == username)
|
||||
// .Include(x => x.Libraries)
|
||||
// .ProjectTo<MemberDto>(_mapper.ConfigurationProvider)
|
||||
// .SingleOrDefaultAsync();
|
||||
// }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue