コード例 #1
0
        public IResult UpdateUserClaims(UserClaimUpdateDto userClaimData)
        {
            // get user
            var userResult = GetByMail(userClaimData.Useremail);

            if (userResult == null)
            {
                return(new ErrorResult(Message.UserRolesUpdateError));
            }
            // Get All claims
            var operationClaims     = _operationClaimService.GetClaims();
            var userOperationClaims = new List <UserOperationClaim>();

            _userOperationClaimService.DeleteUserOperationClaimsByUserId(userResult.Id);

            foreach (var claimId in userClaimData.Claimids)
            {
                userOperationClaims.Add(new UserOperationClaim {
                    User = userResult, OperationClaimId = claimId
                });
            }
            userResult.UserOperationClaims = userOperationClaims;
            _userDal.Update(userResult as AppUser);

            return(new SuccessResult(Message.UserRolesUpdated));
        }