Exemple #1
0
        private string HandleNPrintingUser(Model.User user)
        {
            UserListResponse nPrintingUser = _usersApi.UsersGet(user.Email);

            //User already in NPrinting
            if (nPrintingUser.Data.Items != null && nPrintingUser.Data.Items.Count > 0)
            {
                UserResponseDataItem npUser = nPrintingUser.Data.Items[0];
                _npUserService.UpdateNpUser(npUser, user);
                return(npUser.Id.ToString());
            }
            else
            {
                return(_npUserService.AddNewNpUser(user));
            }
        }
        /**
         * Update an existing NPrinting user
         */
        public void UpdateNpUser(UserResponseDataItem npUser, Model.User adUser)
        {
            var userId = npUser.Id.ToString();

            //There may be changes to the user details in Active Directory
            UserUpdateRequest userUpdReq = new UserUpdateRequest(
                adUser.Email,
                Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                true,
                adUser.Username,
                adUser.Domainaccount ?? "",
                npUser.Timezone,
                npUser.Locale,
                npUser.Folder ?? "",
                npUser.Subfolder ?? "");

            //Update the user details in case of any changes
            _usersApi.UsersIdPut(userId, userUpdReq);
        }