Compare commits

...

4 Commits

3 changed files with 21 additions and 13 deletions

View File

@@ -38,7 +38,7 @@ export class UserComponent extends BasePageComponent implements AfterViewInit {
}
}
private sUsername = null;
private sUser: any = null;
private _bottomSheet = inject(MatBottomSheet);
@@ -49,9 +49,9 @@ export class UserComponent extends BasePageComponent implements AfterViewInit {
this.refreshService.removeAll()
this.refreshService.add(() => {
this.userTable.fetchData();
if (this.sUsername != null) {
this.groupTable.fetchDataByUsername(this.sUsername);
this.moduleTable.fetchDataByUsername(this.sUsername)
if (this.sUser?.username != null) {
this.groupTable.fetchDataByUsername(this.sUser.username);
this.moduleTable.fetchDataByUsername(this.sUser.username)
}
});
@@ -65,14 +65,13 @@ export class UserComponent extends BasePageComponent implements AfterViewInit {
@ViewChild("moduleTable") moduleTable!: ModuleTableComponent;
usersOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length > 0) {
this.sUsername = rows[0].source.username;
if (this.sUsername != null) {
this.groupTable.fetchDataByUsername(this.sUsername);
this.moduleTable.fetchDataByUsername(this.sUsername)
this.openUpdateSheet(rows[0].source);
}
if (rows.length == 1) {
this.sUser = rows[0].source;
this.groupTable.fetchDataByUsername(rows[0].source.username);
this.moduleTable.fetchDataByUsername(rows[0].source.username)
}
else if (rows.length == 0 && this.sUser?.username != null) {
this.openUpdateSheet(this.sUser);
}
}

View File

@@ -16,5 +16,7 @@ namespace DigitalData.UserManager.Infrastructure.Contracts
Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroupAndUser();
Task<IEnumerable<GroupOfUser>> ReadByUsernameAsync(string username);
Task<IEnumerable<GroupOfUser>> ReadByUserIdAsync(int userId);
}
}

View File

@@ -18,6 +18,11 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
return _dbSet.Where(mou => mou.GroupId == groupId);
}
private IQueryable<GroupOfUser> ReadByUserId(int userId)
{
return _dbSet.Where(gou => gou.User!.Id == userId).Include(gou => gou.Group);
}
private IQueryable<GroupOfUser> ReadByUsername(string userName)
{
return _dbSet.Where(gou => gou.User!.Username == userName).Include(gou => gou.Group);
@@ -27,7 +32,7 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
{
return await _dbSet.Where(gou => gou.GroupId == groupId && gou.UserId == userId).ToListAsync();
}
//TODO: Add -Async suffix at the end of async method names
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroup() => await _dbSet.Include(gou => gou.Group).ToListAsync();
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithUser() => await _dbSet.Include(gou => gou.User).ToListAsync();
@@ -35,5 +40,7 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
public async Task<IEnumerable<GroupOfUser>> ReadAllAsyncWithGroupAndUser() => await _dbSet.Include(gou => gou.Group).Include(gou => gou.User).ToListAsync();
public async Task<IEnumerable<GroupOfUser>> ReadByUsernameAsync(string username) => await ReadByUsername(username).ToListAsync();
public async Task<IEnumerable<GroupOfUser>> ReadByUserIdAsync(int userId) => await ReadByUserId(userId).ToListAsync();
}
}