コード例 #1
0
        public async Task <AppUserRoleDto> GetMyRoleInProjectAsync(string userId, int projectId)
        {
            AppUserRole role = await GetRoleIfMember(userId, projectId);

            if (!role.CanViewListOfMembers())
            {
                throw new ForbiddenResponseException("You have not access to this project.");
            }

            return(_mapper.Map <AppUserRole, AppUserRoleDto>(role));
        }
コード例 #2
0
        public async Task <ProjectMemberDto> GetMemberOfProjectAsync(string senderUserId, int projectId, string userId)
        {
            AppUserRole senderRole = await GetRoleIfMember(senderUserId, projectId);

            if (!senderRole.CanViewListOfMembers())
            {
                throw new ForbiddenResponseException("You cannot get list of members of this project");
            }

            AppUserRole role = await _puRepo.GetRoleOfMember(userId, projectId);

            if (!role.IsNone())
            {
                User u = await _userRepo.GetByIdAsync(userId);

                ProjectMemberDto dto = MakeProjectMemberDto(u, role);
                return(dto);
            }
            else
            {
                throw new NotFoundResponseException($"No member with id {userId} in project with id {projectId}");
            }
        }
コード例 #3
0
        public async Task <IEnumerable <ProjectMemberDto> > GetAllMembersOfProjectAsync(string senderUserId, int projectId)
        {
            AppUserRole senderRole = await GetRoleIfMember(senderUserId, projectId);

            if (!senderRole.CanViewListOfMembers())
            {
                throw new ForbiddenResponseException("You cannot get members of this project");
            }

            var members = await _puRepo.GetMembersOfProject(projectId);

            var res = new List <ProjectMemberDto>();

            foreach (User u in members)
            {
                AppUserRole role = await _puRepo.GetRoleOfMember(u.Id, projectId);

                ProjectMemberDto dto = MakeProjectMemberDto(u, role);
                res.Add(dto);
            }

            return(res);
        }