public async Task <IResult> Handle(DeleteUserClaimCommand request, CancellationToken cancellationToken) { var entityToDelete = await _userClaimRepository.GetAsync(x => x.UserId == request.Id); _userClaimRepository.Delete(entityToDelete); await _userClaimRepository.SaveChangesAsync(); return(new SuccessResult(Messages.Deleted)); }
public async Task RemoveClaimAsync(TApplicationUser user, Claim claim) { await userClaimRepository.Delete(user.Id, claim.Type, claim.Value, session); var claimsToDelete = user.Claims.Where(cl => cl.ClaimValue == claim.Value && cl.ClaimType == claim.Type); foreach (var cl in claimsToDelete) { user.Claims.Remove(cl); } }
public async Task RemoveClaimsAsync(ApplicationUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var deleteUserClaimsDto = claims.Select(t => new DeleteUserClaimDto { ClaimType = t.Type, ClaimValue = t.Value, UserId = user.Id }); await _userClaimRepository.Delete(deleteUserClaimsDto); }
public int RemoveClaims(User user, IEnumerable <UserClaim> claims) { IUserClaimRepository uc_repo = _data_repository_factory.GetIdentityDataRepository <IUserClaimRepository>(); foreach (var uc in claims) { UserClaimData ucd = new UserClaimData() { UserID = user.UserId, Id = uc.ClaimID, ClaimType = uc.ClaimType, ClaimValue = uc.ClaimValue }; uc_repo.Delete(ucd); } return(1); }
public async Task RemoveClaimsAsync(TUser user, IEnumerable <Claim> claims, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var userClaims = claims.Select(c => new TUserClaim { UserId = user.Id, ClaimType = c.Type, ClaimValue = c.Value }); foreach (var userClaim in userClaims) { await userClaimRepository.Delete(user.Id, userClaim.ClaimType, userClaim.ClaimValue, session); var uc = user.Claims.FirstOrDefault(x => x.ClaimType == userClaim.ClaimType && x.ClaimValue == userClaim.ClaimValue); user.Claims.Remove(uc); } }
public int ReplaceClaim(User user, UserClaim claim, UserClaim newClaim) { IUserClaimRepository uc_repo = _data_repository_factory.GetIdentityDataRepository <IUserClaimRepository>(); UserClaimData rem_ucd = new UserClaimData() { UserID = user.UserId, Id = claim.ClaimID, ClaimType = claim.ClaimType, ClaimValue = claim.ClaimValue }; uc_repo.Delete(rem_ucd); UserClaimData new_ucd = new UserClaimData() { UserID = user.UserId, Id = newClaim.ClaimID, ClaimType = newClaim.ClaimType, ClaimValue = newClaim.ClaimValue }; return(uc_repo.Save(new_ucd)); }