Beispiel #1
0
        private static void RunSample(string username, string password, string accountId)
        {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("Users-Sample", accountId);

            service.setUserCredentials(username, password);

            // Retrieve the list of all existing users
            UsersFeed feed = service.QueryUsers();

            // Display title and admin for each user
            Console.WriteLine("Listing all users returned");
            foreach (UsersEntry m in feed.Entries)
            {
                Console.WriteLine("User: "******" (" + m.Admin + ")");
            }

            // Create a new users entry
            UsersEntry entry = new UsersEntry();

            entry.Title.Text = "*****@*****.**";
            entry.Admin      = false;
            entry.Permissions.Add(new Permission("online", "readwrite"));
            entry.Permissions.Add(new Permission("local", "noaccess"));

            // Add the user
            Console.WriteLine("Inserting user");
            UsersEntry inserted = service.InsertUser(entry);

            // Update the user we just inserted
            Console.WriteLine("Updating user");
            inserted.Permissions.Add(new Permission("online", "readonly"));
            inserted.Permissions.Add(new Permission("local", "noaccess"));
            UsersEntry updated = service.UpdateUser(inserted);

            // Retrieve the new list of users
            feed = service.QueryUsers();

            // Display title and admin for each user
            Console.WriteLine("Listing all users returned");
            foreach (UsersEntry m in feed.Entries)
            {
                Console.WriteLine("User: "******" (" + m.Admin + ")");
            }

            // Delete the user we inserted and updated
            Console.WriteLine("Deleting user");
            service.DeleteUser(updated);
        }