public Task AddClaimAsync(IdentityUser user, Claim claim) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (claim == null) { throw new ArgumentNullException(nameof(claim)); } var u = _unitOfWork.UserRepository.FindById(user.Id); if (u == null) { throw new ArgumentException("IdentityUser does not correspond to a User entity.", nameof(user)); } var c = new Entities.Claim { ClaimType = claim.Type, ClaimValue = claim.Value, User = u }; u.Claims.Add(c); _unitOfWork.UserRepository.Update(u); return(_unitOfWork.SaveChangesAsync()); }
public virtual void InitializeFromClaim(Claim other) { ClaimType = other?.Type; ClaimValue = other?.Value; }