Exemplo n.º 1
0
        public async Task RemoveMemberAsync(string senderUserId, int projectId, string userId)
        {
            AppUserRole senderRole = await GetRoleIfMember(senderUserId, projectId);

            if (senderUserId == userId)
            {
                if (!senderRole.CanRemoveItself())
                {
                    throw new ForbiddenResponseException("You cannot leave project.");
                }
            }
            else
            {
                if (!senderRole.CanRemoveOtherMember())
                {
                    throw new ForbiddenResponseException("You cannot remove other members.");
                }
            }

            if (!await _puRepo.DoesExistMemberOfProject(userId, projectId))
            {
                throw new NotFoundResponseException("No member with this id in project");
            }

            await _puRepo.DeleteRecordAsync(userId, projectId);
        }