예제 #1
0
        /// <summary>
        /// Gets the currently logged in user account from the ComponentManager.
        /// </summary>
        /// <returns>Currently logged in user account.</returns>
        private static DCO.Objects.UserAccount getCurrentlyLoggedInUserAccount()
        {
            DCU.Objects.UserAccount clientUserAccount =
                ComponentManager.GetComponent <DCU.Objects.UserAccount>();

            return(UserAccountConverter.CovertToCoreUserAccount(clientUserAccount));
        }
예제 #2
0
        /// <summary>
        /// Unlocks a User Account
        /// </summary>
        /// <param name="userAccount">User Account to be unlocked.</param>
        public void UnlockUser(DCU.Objects.UserAccount userAccount)
        {
            // 1.) Get Service
            IUserManagementServices userManagementServices =
                ComponentManager.GetComponent <IUserManagementServices>();

            // 2.) Create Request
            UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest(
                UserManagementActionType.UnlockUser,
                UserAccountConverter.CovertToCoreUserAccount(userAccount));

            // 3.) Send Request
            UserManagementResponse response =
                userManagementServices.UserManagementHandleRequest(request);

            // 4.) Handle Response
            UserAccountActionType userAccountActionType;
            string message;

            if (response.IsRequestSuccessful)
            {
                userAccountActionType = UserAccountActionType.UnlockUser;
                message = response.ResponseMessage;
            }
            else
            {
                userAccountActionType = UserAccountActionType.UnlockUserFailed;
                message = response.ResponseErrorMessage;
            }

            // Get the logged in user account that was used by the server
            // when handling the request.
            DCU.Objects.UserAccount clientUserAccountLoggedIn =
                UserAccountConverter.CovertToClientUserAccount(response.RequestorUserAccount);

            UserAccountEventArgs userAccountEventArgs =
                createUserAccountEventArgs(
                    userAccountActionType,
                    null,
                    clientUserAccountLoggedIn,
                    message);

            // Broadcast to UserAccountEventARgs that an unlock user was triggered.
            EventBus <UserAccountEventArgs> .Broadcast(
                this,
                userAccountEventArgs);
        }
예제 #3
0
        /// <summary>
        /// Edits a User Account
        /// </summary>
        /// <param name="userAccount">User Account to be edited.</param>
        public void EditUser(DCU.Objects.UserAccount userAccount)
        {
            // 1.) Get Service
            IUserManagementServices userManagementServices =
                ComponentManager.GetComponent <IUserManagementServices>();

            // 2.) Create Request
            UserManagementRequest request = UserManagementHelper.CreateUserManagementRequest(
                UserManagementActionType.EditUser,
                UserAccountConverter.CovertToCoreUserAccount(userAccount));

            // 3.) Send Request
            UserManagementResponse response =
                userManagementServices.UserManagementHandleRequest(request);

            // 4.) Handle Response
            if (response.IsRequestSuccessful)
            {
                // Broadcast to UserAccountEventArgs that add was successful.
                UpdateUsers(UserAccountActionType.EditUser);
            }
            else
            {
                // Get the logged in user account that was used by the server
                // when handling the request.
                DCU.Objects.UserAccount clientUserAccountLoggedIn =
                    UserAccountConverter.CovertToClientUserAccount(response.RequestorUserAccount);

                UserAccountEventArgs userAccountEventArgs =
                    createUserAccountEventArgs(
                        UserAccountActionType.EditUserFailed,
                        null,
                        clientUserAccountLoggedIn,
                        response.ResponseErrorMessage);

                // Broadcast to UserAccountEventArgs that add failed.
                EventBus <UserAccountEventArgs> .Broadcast(
                    this,
                    userAccountEventArgs);
            }
        }