private async Task AssignNullToOrphanedProfiles(string[] contentItemIds, string contentItemId) { var existingProfiles = await _session.Query <ContentItem>() .With <ProfileGroupedPartIndex>(x => x.GroupContentItemId == contentItemId) .ListAsync(); foreach (var existingProfile in existingProfiles) { if (contentItemIds.Contains(existingProfile.ContentItemId)) { continue; } await _profileGroupsService.AssignGroupAsync(existingProfile, null); } }
public override async Task RemovingAsync(RemoveContentContext context, ProfilePart part) { // Check if the user has permission to delete orchard user if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext?.User, Permissions.ManageUsers)) { return; } await _profileGroupsService.AssignGroupAsync(part.ContentItem, null); var user = await _userService.GetUserByUniqueIdAsync(part.UserIdentifier); if (user != null) { await _userManager.DeleteAsync(user); } }