Exemple #1
0
        public async Task <OrganizationUserInvitationListRp> GetUserInvitations()
        {
            string loggedUserEmail = _identityService.GetUserEmail();

            var invitations = await _organizationUserInvitationRepository.GetOrganizationUserInvitationByEmail(loggedUserEmail);

            OrganizationUserInvitationListRp list = new OrganizationUserInvitationListRp();

            list.Items = invitations.Select(x => new OrganizationUserInvitationListItemRp()
            {
                InvitationId     = x.OrganizationUserInvitationId,
                OrganizationId   = x.OrganizationId,
                OrganizationName = x.Organization.Name,
                UserEmail        = x.UserEmail,
                Role             = x.Role,
                InvitationStatus = x.InvitationStatus,
                AcceptedDate     = x.AcceptedDate,
                CreationDate     = x.CreationDate
            }).ToList();

            return(list);
        }
Exemple #2
0
        public async Task <OrganizationUserInvitationListRp> GetInvitations(Guid organizationId)
        {
            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);
            }

            //PipelineRole role = user.GetRoleInOrganization(organizationId);
            //if (role != PipelineRole.OrganizationAdmin)
            //{
            //    await _domainManagerService.AddForbidden($"You are not authorized to retreive the invitations in this organization.");
            //    return null;
            //}

            OrganizationUserInvitationListRp list = new OrganizationUserInvitationListRp();

            list.Items = organization.UserInvitations.Select(x => new OrganizationUserInvitationListItemRp()
            {
                InvitationId     = x.OrganizationUserInvitationId,
                UserEmail        = x.UserEmail,
                Role             = x.Role,
                InvitationStatus = x.InvitationStatus,
                AcceptedDate     = x.AcceptedDate,
                CreationDate     = x.CreationDate
            }).OrderByDescending(x => x.CreationDate).ToList();

            return(list);
        }