public async Task <bool> KickMember(string groupId, string userId) { var currentUser = await profileService.GetCurrentUser(); var group = await database.GroupRepository.FindById(groupId) ?? throw new EntityNotFoundException("Group not found"); if (currentUser.Id == userId) { throw new NoPermissionsException("You are not allowed to kick yourself"); } if (!RemoveMemberPermissionSmartEnum.FromValue((int)group.RemoveMemberPermission) .ValidatePermission(currentUser.Id, group)) { throw new NoPermissionsException("You are not allowed to kick members from this group"); } var member = GetMember(userId, group); if (!member.IsAccepted) { throw new NoPermissionsException("This user is not member of this group"); } database.GroupMemberRepository.Delete(member); if (await database.Complete()) { await notifier.Push(NotificationMessages.MemberKickedNotification(group.Name), userId, NotificationType.MemberKicked); return(true); } return(false); }