Projekt

Obecné

Profil

« Předchozí | Další » 

Revize e951f8f9

Přidáno uživatelem Milan Hotovec před téměř 4 roky(ů)

Added senior name to DTO

Zobrazit rozdíly:

src/Core/Domain/Leuze.Core.Domain/Domains/Users/DTOs/UserShortDto.cs
5 5
    /// <summary>
6 6
    /// 
7 7
    /// </summary>
8
    public record UserShortDto(Guid Id, string Name, Guid? SeniorId, Guid RoleId, string RoleName);
8
    public record UserShortDto(Guid Id, string Name, Guid? SeniorId, string SeniorName, Guid RoleId, string RoleName);
9 9
}
src/Core/Infrastructure/Leuze.Core.Infrastructure.Persistence/Repository/DomainUserRepository.cs
73 73
        /// <inheritdoc/>
74 74
        public async Task<List<UserShortDto>> GetListAsync(string? limitForRole)
75 75
        {
76
            var query = dbSet.Include(o => o.User).ThenInclude(o => o.Roles).AsQueryable();
76
            var query = dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles).AsQueryable();
77 77

  
78 78
            if (limitForRole is not null) query = query.Where(o => o.User.Roles.Any(a => a.NormalizedName == limitForRole.ToUpper()));
79 79

  
80
            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();
80
            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();
81 81
        }
82 82

  
83 83
        /// <inheritdoc/>
84 84
        public async Task<List<UserShortDto>> GetAllNonAdminUsers()
85
            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
85
            => await dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles)
86 86
                .Where(o => o.User.Roles.Any(a => a.NormalizedName != "ADMIN"))
87
                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
87
                .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();
88 88

  
89 89
        /// <inheritdoc/>
90 90
        public async Task<List<UserShortDto>> GetAllTLUsers()
91
            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
91
            => await dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles)
92 92
                .Where(o => o.User.Roles.Any(a => a.NormalizedName == "TL"))
93
                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
93
                .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();
94 94

  
95 95
        /// <inheritdoc/>
96 96
        public async Task<List<UserShortDto>> GetAllMAUsersFromTL(Guid id)
97
            => await dbSet.Include(o => o.User).ThenInclude(o => o.Roles)
97
            => await dbSet.Include(o => o.SeniorUser).Include(o => o.User).ThenInclude(o => o.Roles)
98 98
                .Where(o => o.SeniorUserId.HasValue && o.SeniorUserId.Value == id && o.User.Roles.Any(a => a.NormalizedName == "MA"))
99
                .Select(o => new UserShortDto(o.UserId, o.Name.FullName, o.SeniorUserId, o.User.Roles.First().Id, o.User.Roles.First().Name)).ToListAsync();
99
                .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();
100 100
    }
101 101
}
src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/GoalDefinitions/Queries/GetAllUnassignedInArea.cs
40 40
                var id = Guid.Parse(state.User!.FindFirst(ClaimTypes.NameIdentifier)!.Value);
41 41
                var user = await _domainUserRepo.GetByIdAsync(id);
42 42

  
43
                //TODO: Change with list of TL and MA only
44 43
                //var goalDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId);
45
                var allUsers = await _domainUserRepo.GetListAsync(id);
44
                var allUsers = await _domainUserRepo.GetAllNonAdminUsers();
46 45
                //allUsers = allUsers.Where(o => o.) //Remove admins
47 46
                var areaDefs = await _goalDefinitionRepo.GetAllForAreaAsync(request.areaId);
48
                var assignedList = areaDefs.Select(o => new UserShortDto(o.Owner.UserId, o.Owner.Name.FullName)).ToList();
47
                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();
49 48

  
50 49

  
51 50
                var unassignedUsers = allUsers.Except(assignedList).ToList();
src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
42 42

  
43 43
        public async Task<List<GoalDefinition>> GetAllForAreaAsync(Guid areaId)
44 44
        {
45
            return await dbSet.Include(item => item.Creator).Include(item => item.Owner).Where(item => item.GDAreaId == areaId).ToListAsync();
45
            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();
46 46
        }
47 47

  
48 48
        public async Task<List<GoalDefinition>> GetAllForUserAsync(Guid userId)

Také k dispozici: Unified diff