commit e951f8f9d2ae93558493b195c5eaeb13bd2e8d69
Author: Milan Hotovec <silent@students.zcu.cz>
Date:   Thu May 27 21:10:18 2021 +0200

    Added senior name to DTO

diff --git a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
index a961eb5..045fce4 100644
--- a/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
+++ b/src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
@@ -5,5 +5,5 @@ namespace Leuze.Core.Domain.Domains.Users.DTOs
     /// <summary>
     /// 
     /// </summary>
-    public record UserShortDto(Guid Id, string Name, Guid? SeniorId, Guid RoleId, string RoleName);
+    public record UserShortDto(Guid Id, string Name, Guid? SeniorId, string SeniorName, Guid RoleId, string RoleName);
 }
diff --git a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
index 8e85ef1..d986aa3 100644
--- a/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
+++ b/src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
@@ -73,29 +73,29 @@ namespace Leuze.Core.Infrastructure.Persistence.Repository
         /// <inheritdoc/>
         public async Task<List<UserShortDto>> GetListAsync(string? limitForRole)
         {
-            var query = dbSet.Include(o => o.User).ThenInclude(o => o.Roles).AsQueryable();
+            var query = dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles).AsQueryable();
 
             if (limitForRole is not null) query = query.Where(o => o.User.Roles.Any(a => a.NormalizedName == limitForRole.ToUpper()));
 
-            return await query.Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
+            return await query.Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.SeniorUser != null ? o.SeniorUser.Name.FullName : "", o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
         }
 
         /// <inheritdoc/>
         public async Task<List<UserShortDto>> GetAllNonAdminUsers()
-            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
+            => await dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles)
                 .Where(o => o.User.Roles.Any(a => a.NormalizedName != "ADMIN"))
-                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
+                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.SeniorUser != null ? o.SeniorUser.Name.FullName : "", o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
 
         /// <inheritdoc/>
         public async Task<List<UserShortDto>> GetAllTLUsers()
-            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
+            => await dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles)
                 .Where(o => o.User.Roles.Any(a => a.NormalizedName == "TL"))
-                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
+                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.SeniorUser != null ? o.SeniorUser.Name.FullName : "", o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
 
         /// <inheritdoc/>
         public async Task<List<UserShortDto>> GetAllMAUsersFromTL(Guid id)
-            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
+            => await dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles)
                 .Where(o => o.SeniorUserId.HasValue && o.SeniorUserId.Value == id && o.User.Roles.Any(a => a.NormalizedName == "MA"))
-                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
+                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.SeniorUser != null ? o.SeniorUser.Name.FullName : "", o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
     }
 }
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs
index 092647d..dc4a56a 100644
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs
@@ -40,12 +40,11 @@ namespace Leuze.Modules.Goal.Application.CQRS.GoalDefinitions.Queries
                 var id = Guid.Parse(state.User!.FindFirst(ClaimTypes.NameIdentifier)!.Value);
                 var user = await _domainUserRepo.GetByIdAsync(id);
 
-                //TODO: Change with list of TL and MA only
                 //var goalDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId);
-                var allUsers = await _domainUserRepo.GetListAsync(id);
+                var allUsers = await _domainUserRepo.GetAllNonAdminUsers();
                 //allUsers = allUsers.Where(o => o.) //Remove admins
                 var areaDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId);
-                var assignedList = areaDefs.Select(o => new UserShortDto(o.Owner.UserId, o.Owner.Name.FullName)).ToList();
+                var assignedList = areaDefs.Select(o => new UserShortDto(o.Owner.UserId, o.Owner.Name.FullName, o.Owner.SeniorUserId, o.Owner.SeniorUser?.Name.FullName ?? "", o.Owner.User.Roles.First().Id, o.Owner.User.Roles.First().Name)).ToList();
 
 
                 var unassignedUsers = allUsers.Except(assignedList).ToList();
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
index 6a04534..8e25468 100644
--- a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
@@ -42,7 +42,7 @@ namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
 
         public async Task<List<GoalDefinition>> GetAllForAreaAsync(Guid areaId)
         {
-            return await dbSet.Include(item => item.Creator).Include(item => item.Owner).Where(item => item.GDAreaId == areaId).ToListAsync();
+            return await dbSet.Where(item => item.GDAreaId == areaId).Include(item => item.Creator).Include(item => item.Owner).ThenInclude(item => item.SeniorUser).Include(item => item.Owner.User.Roles).ToListAsync();
         }
 
         public async Task<List<GoalDefinition>> GetAllForUserAsync(Guid userId)
