public async Task <ProjectUserInvitationListRp> GetInvitations(Guid organizationId, Guid projectId) { string loggedUserId = _identityService.GetUserId(); User user = await _userRepository.GetUser(loggedUserId); Organization organization = user.FindOrganizationById(organizationId); if (organization == null) { await _domainManagerService.AddNotFound($"The organzation with id {organizationId} does not exists."); return(null); } Project project = user.FindProjectById(projectId); if (project == null) { await _domainManagerService.AddNotFound($"The project with id {projectId} does not exists."); return(null); } //PipelineRole role = user.GetRoleInProject(projectId); //if (role != PipelineRole.ProjectAdmin) //{ // await _domainManagerService.AddForbidden($"You are not authorized to invite users in this project."); // return null; //} ProjectUserInvitationListRp list = new ProjectUserInvitationListRp(); list.Items = project.UserInvitations.Select(x => new ProjectUserInvitationListItemRp() { InvitationId = x.ProjectUserInvitationId, UserEmail = x.UserEmail, Role = x.Role, InvitationStatus = x.InvitationStatus, AcceptedDate = x.AcceptedDate, CreationDate = x.CreationDate }).ToList(); return(list); }
public async Task <ProjectUserInvitationListRp> GetUserInvitations() { string loggedUserEmail = _identityService.GetUserEmail(); var invitations = await _projectUserInvitationRepository.GetProjectUserInvitationByEmail(loggedUserEmail); ProjectUserInvitationListRp list = new ProjectUserInvitationListRp(); list.Items = invitations.Select(x => new ProjectUserInvitationListItemRp() { InvitationId = x.ProjectUserInvitationId, OrganizationId = x.Project.OrganizationId, OrganizationName = x.Project.Organization.Name, ProjectId = x.ProjectId, ProjectName = x.Project.Name, UserEmail = x.UserEmail, Role = x.Role, InvitationStatus = x.InvitationStatus, AcceptedDate = x.AcceptedDate, CreationDate = x.CreationDate }).OrderByDescending(x => x.CreationDate).ToList(); return(list); }