public Task RemoveClaimAsync(TUser user, Claim claim) { if (user == null) { throw new ArgumentNullException("user"); } if (claim == null) { throw new ArgumentNullException("claim"); } UserClaimRepository.Delete(UserClaimRepository.GetByWhere(new Dictionary <string, object> { { "UserId", user.Id }, { "ClaimType", claim.Type }, { "ClaimValue", claim.Value } }).First()); return(Task.FromResult <object>(null)); }
public Task <IList <Claim> > GetClaimsAsync(TUser user) { if (user == null) { return(Task.FromResult <IList <Claim> >(new List <Claim>())); } var where = new Dictionary <string, object> { { "UserId", user.Id } }; if (UserClaimRepository == null) { return(Task.FromResult <IList <Claim> >(new List <Claim>())); } var userClaims = UserClaimRepository.GetByWhere(where).ToList(); if (!userClaims.Any()) { return(Task.FromResult <IList <Claim> >(new List <Claim>())); } var claims = userClaims.Select(x => new Claim(x.ClaimType, x.ClaimValue)); return(Task.FromResult <IList <Claim> >(claims.ToList())); }