private static bool DeleteUser(string authToken, string uniqueIdentifier,
     bool deleteResponses)
 {
     var service = new UserManagementServiceClient();
     var result = service.DeleteUser(authToken, uniqueIdentifier, deleteResponses);
     if (result.CallSuccess) return true;
     Console.WriteLine(result.FailureMessage);
     return false;
 }
예제 #2
0
        public void Delete()
        {
            System.Console.WriteLine("---Delete user---");

            System.Console.Write("Id:");
            int id = int.Parse(System.Console.ReadLine());

            GetUserRequest requestGet = new GetUserRequest
            {
                UserId = id
            };

            GetUserResponse responseGet = _client.GetUser(requestGet);

            if (responseGet == null)
            {
                System.Console.WriteLine("Error: response is null");
                return;
            }

            if (!responseGet.Success)
            {
                System.Console.WriteLine($"Error: {responseGet.Message}");
                return;
            }

            System.Console.WriteLine("Success: User found");

            System.Console.WriteLine("Do you want to delete the user?[Y/n]");

            if (System.Console.ReadKey(true).Key == System.ConsoleKey.Y)
            {
                DeleteUserRequest requestDelete = new DeleteUserRequest
                {
                    UserId = id
                };

                DeleteUserResponse responseDelete = _client.DeleteUser(requestDelete);

                if (responseDelete == null)
                {
                    System.Console.WriteLine("Error: response is null");
                }
                else
                if (!responseDelete.Success)
                {
                    System.Console.WriteLine($"Error: {responseDelete.Message}");
                }
                else
                {
                    System.Console.WriteLine($"Success: User deleted");
                }
            }

            System.Console.WriteLine("------------------");
        }
예제 #3
0
        /// <summary>
        /// Delete the specified user.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="uniqueIdentifier">The unique identifier of the user to delete.</param>
        /// <param name="deleteResponses">Indicates whether the user's responses should be deleted as well.</param>
        /// <remarks>
        /// Users and their responses are "soft deleted" from the database. Records are flagged as deleted, but
        /// data is not removed from the database permanently.
        /// </remarks>
        private static bool DeleteUser(string authenticationToken, string uniqueIdentifier, bool deleteResponses)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.DeleteUser(authenticationToken, uniqueIdentifier, deleteResponses);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return false;
            }

            // The DeleteUser method does not return ResultData. Return true if the operation completed successfully.
            return true;
        }