public async Task <PagedResultDto <UserProfileListDto> > GetUserProfiles(GetUsersInput input)
        {
            var query = GetUsersFilteredQuery(input);

            var userCount = await query.CountAsync();

            var users = await query
                        .OrderBy(input.Sorting)
                        .PageBy(input)
                        .ToListAsync();

            var userProfileListDtos = ObjectMapper.Map <List <UserProfileListDto> >(users);

            foreach (var userProfileListDto in userProfileListDtos)
            {
                if (userProfileListDto.ProfilePictureId != null)
                {
                    userProfileListDto.ProfilePicture = await _profileAppService.GetProfilePictureByIdString(userProfileListDto.ProfilePictureId);
                }
                ;
            }

            await FillRoleProfileNames(userProfileListDtos);

            return(new PagedResultDto <UserProfileListDto>(
                       userCount,
                       userProfileListDtos
                       ));
        }
Example #2
0
        public async Task <PagedResultDto <UserProfileListDto> > GetUserTeamProfiles(GetUsersTeamInput input)
        {
            var query     = GetUsersTeamFilteredQuery(input, input.TeamId, input.isSelected);
            var userCount = await query.CountAsync();

            var users = await query
                        .OrderBy(input.Sorting)
                        .ToListAsync();


            var userProfileListDtos = ObjectMapper.Map <List <UserProfileListDto> >(users);

            foreach (var userProfileListDto in userProfileListDtos)
            {
                if (userProfileListDto.ProfilePictureId != null)
                {
                    userProfileListDto.ProfilePicture = await _profileAppService.GetProfilePictureByIdString(userProfileListDto.ProfilePictureId);


                    var teamMemberQuery = _teamMemberRepository.GetAll()
                                          .Where(e => e.TeamId == input.TeamId && e.UserId == userProfileListDto.Id);

                    var memberquery = from o in teamMemberQuery

                                      select new GetTeamMemberForViewDto()
                    {
                        TeamMember = new TeamMemberDto
                        {
                            Id       = o.Id,
                            SysRefId = o.SysRefId,
                            ReportingTeamMemberId = o.ReportingTeamMemberId,
                            RoleOrderNumber       = o.SysRefFk.OrderNumber
                        },
                    };

                    var teamMemberListDtos = await memberquery
                                             .ToListAsync();

                    foreach (var teamMember in teamMemberListDtos)
                    {
                        userProfileListDto.TeamMemberId    = teamMember.TeamMember.Id;
                        userProfileListDto.SelectedRole    = teamMember.TeamMember.SysRefId;
                        userProfileListDto.ReportingTo     = teamMember.TeamMember.ReportingTeamMemberId;
                        userProfileListDto.RoleOrderNumber = teamMember.TeamMember.RoleOrderNumber;
                    }
                }
                ;
            }

            await FillRoleProfileNames(userProfileListDtos);

            return(new PagedResultDto <UserProfileListDto>(
                       userCount,
                       userProfileListDtos
                       ));
        }
Example #3
0
        public async Task <PagedResultDto <GetApprovalRequestForViewDto> > GetApprovalRequest(GetCustomApprovalRequestsInput input)
        {
            var filteredApprovalRequests = _approvalRequestRepository.GetAll()
                                           .Include(e => e.SysRefFk)
                                           .Include(e => e.SysStatusFk)
                                           .Include(e => e.UserFk)
                                           .WhereIf(input.ReferenceId != null, e => e.ReferenceId == input.ReferenceId)
                                           .WhereIf(input.SysRefId != null, e => e.ReferenceId == input.SysRefId)
                                           .WhereIf(input.SysStatusId != null, e => e.OrderNo == input.SysStatusId);

            var pagedAndFilteredApprovalRequests = filteredApprovalRequests
                                                   .OrderBy("OrderNo, RankNo, Amount asc");

            var approvalRequests = from o in pagedAndFilteredApprovalRequests
                                   join o1 in _lookup_sysRefRepository.GetAll() on o.SysRefId equals o1.Id into j1
                                   from s1 in j1.DefaultIfEmpty()

                                   join o2 in _lookup_sysStatusRepository.GetAll() on o.SysStatusId equals o2.Id into j2
                                   from s2 in j2.DefaultIfEmpty()

                                   join o3 in _lookup_userRepository.GetAll() on o.UserId equals o3.Id into j3
                                   from s3 in j3.DefaultIfEmpty()

                                   select new GetApprovalRequestForViewDto()
            {
                ApprovalRequest = new ApprovalRequestDto
                {
                    ReferenceId   = o.ReferenceId,
                    OrderNo       = o.OrderNo,
                    UserId        = o.UserId,
                    RankNo        = o.RankNo,
                    Amount        = o.Amount,
                    Remark        = o.Remark,
                    Id            = o.Id,
                    SysStatusId   = o.SysStatusId,
                    SysStatusName = s2.Name.ToString()
                },

                SysRefTenantId = s1 == null ? "" : s1.TenantId.ToString(),
                SysStatusName    = s2 == null ? "" : s2.Name.ToString(),
                UserName         = s3 == null ? "" : s3.UserName.ToString(),
                FullName         = s3 == null ? "" : s3.FullName.ToString(),
                EmailAddress     = s3 == null ? "" : s3.EmailAddress.ToString(),
                ProfilePictureId = s3 == null ? Guid.Empty : s3.ProfilePictureId,
                ProfilePicture   = ""
            };

            var totalCount = await filteredApprovalRequests.CountAsync();

            var approvalRequestsListDtos = await approvalRequests.ToListAsync();

            int orderNo = 0;

            foreach (var approvalRequest in approvalRequestsListDtos)
            {
                orderNo += 1;
                Guid profilePictureId = approvalRequest.ProfilePictureId.Value;
                approvalRequest.ProfilePicture = await _profileAppService.GetProfilePictureByIdString(profilePictureId);

                approvalRequest.ApprovalRequest.OrderNo = orderNo;
            }

            return(new PagedResultDto <GetApprovalRequestForViewDto>(
                       totalCount,
                       approvalRequestsListDtos
                       ));
        }
Example #4
0
        public async Task <PagedResultDto <GetTeamMemberForViewDto> > GetTeamMembers(GetAllTeamMembersInput input)
        {
            var filteredTeamMembers = _teamMemberRepository.GetAll()
                                      .Include(e => e.TeamFk)
                                      .Include(e => e.UserFk)
                                      .Include(e => e.SysRefFk)
                                      .Include(e => e.SysStatusFk)
                                      .WhereIf(!string.IsNullOrWhiteSpace(input.Filter), e => false || e.Remark.Contains(input.Filter))
                                      .WhereIf(!string.IsNullOrWhiteSpace(input.RemarkFilter), e => e.Remark == input.RemarkFilter)
                                      .WhereIf(!string.IsNullOrWhiteSpace(input.TeamNameFilter), e => e.TeamFk != null && e.TeamFk.Name == input.TeamNameFilter)
                                      .WhereIf(!string.IsNullOrWhiteSpace(input.UserNameFilter), e => e.UserFk != null && e.UserFk.Name == input.UserNameFilter)
                                      .WhereIf(input.ReportingTeamMemberIdFilter != null, e => e.ReportingTeamMemberId == input.ReportingTeamMemberIdFilter)
                                      .WhereIf(input.TeamIdFilter != null, e => e.TeamFk.Id == input.TeamIdFilter)
                                      .WhereIf(!string.IsNullOrWhiteSpace(input.SysStatusNameFilter), e => e.SysStatusFk != null && e.SysStatusFk.Name == input.SysStatusNameFilter);

            var pagedAndFilteredTeamMembers = filteredTeamMembers
                                              .OrderBy(input.Sorting ?? "id asc")
                                              .PageBy(input);

            var teamMembers = from o in pagedAndFilteredTeamMembers
                              join o1 in _lookup_teamRepository.GetAll() on o.TeamId equals o1.Id into j1
                              from s1 in j1.DefaultIfEmpty()

                              join o2 in _lookup_userRepository.GetAll() on o.UserId equals o2.Id into j2
                              from s2 in j2.DefaultIfEmpty()

                              join o3 in _lookup_sysRefRepository.GetAll() on o.SysRefId equals o3.Id into j3
                              from s3 in j3.DefaultIfEmpty()

                              join o4 in _lookup_sysStatusRepository.GetAll() on o.SysStatusId equals o4.Id into j4
                              from s4 in j4.DefaultIfEmpty()


                              orderby o.SysRefFk.OrderNumber

                              select new GetTeamMemberForViewDto()
            {
                TeamMember = new TeamMemberDto
                {
                    Remark = o.Remark,
                    ReportingTeamMemberId = o.ReportingTeamMemberId,
                    Id = o.Id
                },
                TeamName = s1 == null ? "" : s1.Name.ToString(),
                UserName         = s2 == null ? "" : s2.Name.ToString(),
                SysRefTenantId   = s3 == null ? "" : s3.TenantId.ToString(),
                SysStatusName    = s4 == null ? "" : s4.Name.ToString(),
                FullName         = s2 == null ? "" : s2.FullName.ToString(),
                EmailAddress     = s2 == null ? "" : s2.EmailAddress.ToString(),
                SelectedRoleName = s3 == null ? "" : s3.RefCode.ToString(),
                ProfilePictureId = s2 == null ? Guid.Empty : s2.ProfilePictureId,
                ProfilePicture   = ""
            };

            var teamMemberListDtos = await teamMembers.ToListAsync();

            foreach (var teamMember in teamMemberListDtos)
            {
                Guid profilePictureId = teamMember.ProfilePictureId.Value;
                teamMember.ProfilePicture = await _profileAppService.GetProfilePictureByIdString(profilePictureId);
            }

            var totalCount = await filteredTeamMembers.CountAsync();

            return(new PagedResultDto <GetTeamMemberForViewDto>(
                       totalCount,
                       teamMemberListDtos
                       ));
        }