Пример #1
0
        public virtual IUserClaimState ToUserClaimState()
        {
            var state = new UserClaimState(true);

            if (this.ClaimId != null && this.ClaimId.HasValue)
            {
                state.ClaimId = this.ClaimId.Value;
            }
            state.ClaimType  = this.ClaimType;
            state.ClaimValue = this.ClaimValue;
            if (this.Active != null && this.Active.HasValue)
            {
                state.Active = this.Active.Value;
            }
            if (this.Version != null && this.Version.HasValue)
            {
                state.Version = this.Version.Value;
            }
            state.UserId    = this.UserId;
            state.CreatedBy = this.CreatedBy;
            if (this.CreatedAt != null && this.CreatedAt.HasValue)
            {
                state.CreatedAt = this.CreatedAt.Value;
            }
            state.UpdatedBy = this.UpdatedBy;
            if (this.UpdatedAt != null && this.UpdatedAt.HasValue)
            {
                state.UpdatedAt = this.UpdatedAt.Value;
            }

            return(state);
        }
Пример #2
0
        public virtual IUserClaimState Get(int claimId, bool forCreation, bool nullAllowed)
        {
            UserClaimId globalId = new UserClaimId(_userState.UserId, claimId);

            if (_loadedUserClaimStates.ContainsKey(globalId))
            {
                return(_loadedUserClaimStates[globalId]);
            }
            if (forCreation || ForReapplying)
            {
                var state = new UserClaimState(ForReapplying);
                state.UserClaimId = globalId;
                _loadedUserClaimStates.Add(globalId, state);
                return(state);
            }
            else
            {
                var state = UserClaimStateDao.Get(globalId, nullAllowed);
                if (state != null)
                {
                    _loadedUserClaimStates.Add(globalId, state);
                }
                return(state);
            }
        }
Пример #3
0
 public static CreateUserClaim ToCreateUserClaim(this UserClaimState state)
 {
     return(state.ToCreateUserClaim <CreateUserClaim>());
 }
Пример #4
0
 public static MergePatchUserClaim ToMergePatchUserClaim(this UserClaimState state)
 {
     return(state.ToMergePatchUserClaim <MergePatchUserClaim>());
 }
Пример #5
0
 public static RemoveUserClaim ToRemoveUserClaim(this UserClaimState state)
 {
     return(state.ToRemoveUserClaim <RemoveUserClaim>());
 }
Пример #6
0
 public static IUserClaimCommand ToCreateOrMergePatchUserClaim(this UserClaimState state)
 {
     return(state.ToCreateOrMergePatchUserClaim <CreateUserClaim, MergePatchUserClaim>());
 }