示例#1
0
        public static async Task Run(ApiHttpClient client)
        {
            UserResponse user;

            using (var logger = new Program.Logger("Loading all users ... ", client))
            {
                var users = await new UsersRequest().LoadResultAsync(client);
                logger.Write("{0} users loaded.", users.Count());
            }

            using (var logger = new Program.Logger("Creating new user ... ", client))
            {
                user = await new UserPutRequest(new UserCreateParameter
                {
                    Email     = Guid.NewGuid() + "@server.com",
                    FirstName = "Mario",
                    LastName  = "Mustermann",
                    IsEnabled = true,
                    Password  = "******"
                }).LoadResultAsync(client);
                logger.Write("User '{0} {1}' created.", user.FirstName, user.LastName);
            }

            using (var logger = new Program.Logger("Loading specific user ... ", client))
            {
                user = await new UserRequest(user.Id).LoadResultAsync(client);
                logger.Write("User '{0} {1}' loaded.", user.FirstName, user.LastName);
            }

            using (var logger = new Program.Logger("Updating user ... ", client))
            {
                user = await new UserPostRequest(user.Id, new UserUpdateParameter
                {
                    FirstName = "Maria",
                    IsEnabled = false,
                    LastName  = "Musterfrau"
                }).LoadResultAsync(client);
                logger.Write("User '{0} {1}' updated.", user.FirstName, user.LastName);
            }

            using (var logger = new Program.Logger("Creating user and merging it ... ", client))
            {
                var anotherUser = await new UserPutRequest(new UserCreateParameter
                {
                    Email    = Guid.NewGuid() + "@server.com",
                    Password = "******"
                }).LoadResultAsync(client);

                user = await new UserMergeAndDeleteRequest(anotherUser.Id, user.Id).LoadResultAsync(client);
                logger.Write("User '{0} {1}' merged into.", user.FirstName, user.LastName);
            }

            using (var logger = new Program.Logger("Deleting user ... ", client))
            {
                user = await new UserDeleteRequest(user.Id).LoadResultAsync(client);
                logger.Write("User '{0} {1}' deleted.", user.FirstName, user.LastName);
            }
        }
示例#2
0
        private static async Task RunApiKeyRequests(ApiHttpClient client, int mandatorId)
        {
            using (var logger = new Program.Logger("Loading all API keys ... ", client))
            {
                var apiKeys = await new ApiKeysRequest().LoadResultAsync(client);
                logger.Write("{0} keys loaded.", apiKeys.Count());
            }

            using (var logger = new Program.Logger("Loading API keys for specific mandator ... ", client))
            {
                var apiKeys = await new ApiKeysRequest(mandatorId).LoadResultAsync(client);
                logger.Write("{0} keys loaded.", apiKeys.Count());
            }

            ApiKeyResponse apiKey;

            using (var logger = new Program.Logger("Creating new API key ... ", client))
            {
                apiKey = await new ApiKeyPutRequest(new ApiKeyCreateParameter
                {
                    Name       = "My new key",
                    MandatorId = mandatorId,
                    IsEnabled  = true
                }).LoadResultAsync(client);
                logger.Write("API key '{0}' created.", apiKey.Name);
            }

            using (var logger = new Program.Logger("Updating API key ... ", client))
            {
                apiKey = await new ApiKeyPostRequest(apiKey.Id, new ApiKeyUpdateParameter
                {
                    Name         = apiKey.Name + " *updated*",
                    IsEnabled    = false,
                    AccessLevels = new[] { ApiKeyAccessLevel.Jobs, ApiKeyAccessLevel.Applicants }
                }).LoadResultAsync(client);
                logger.Write("API key '{0}' updated.", apiKey.Name);
            }

            using (var logger = new Program.Logger("Deleting API key ... ", client))
            {
                apiKey = await new ApiKeyDeleteReqeust(apiKey.Id).LoadResultAsync(client);
                logger.Write("API key '{0}' deleted.", apiKey.Name);
            }
        }
示例#3
0
        public static async Task Run(ApiHttpClient client)
        {
            MandatorResponse mandator;

            using (var logger = new Program.Logger("Loading current mandator ... ", client))
            {
                mandator = await new MandatorRequest().LoadResultAsync(client);
                logger.Write("Mandator '{0}' loaded.", mandator.Name);
            }

            using (var logger = new Program.Logger("Re-loading current mandator (should hit cache) ... ", client))
            {
                mandator = await new MandatorRequest().LoadResultAsync(client);
                logger.Write("Mandator '{0}' loaded.", mandator.Name);
            }

            using (var logger = new Program.Logger("Loading knowledge tree ... ", client))
            {
                var knowledgeTree = await new KnowledgeTreeRequest().LoadResultAsync(client);
                logger.Write("Knowledge tree loaded ({0} jobProfiles).", knowledgeTree.JobProfiles.Count());
            }

            using (var logger = new Program.Logger("Loading all mandators ... ", client))
            {
                var mandators = await new MandatorsRequest().LoadResultAsync(client);
                logger.Write("{0} mandators loaded.", mandators.Count());
            }

            await RunApiKeyRequests(client, mandator.Id);

            using (var logger = new Program.Logger("Creating new mandator ... ", client))
            {
                mandator = await new MandatorPutRequest(new MandatorCreateParameter
                {
                    Name = "My new mandator " + Guid.NewGuid()
                }).LoadResultAsync(client);
                logger.Write("Mandator '{0}' created.", mandator.Name);
            }

            using (var logger = new Program.Logger("Loading specific mandator ... ", client))
            {
                mandator = await new MandatorRequest(mandator.Id).LoadResultAsync(client);
                logger.Write("Mandator '{0}' loaded.", mandator.Name);
            }

            using (var logger = new Program.Logger("Re-loading specific mandator (should hit cache) ... ", client))
            {
                mandator = await new MandatorRequest(mandator.Id).LoadResultAsync(client);
                logger.Write("Mandator '{0}' loaded.", mandator.Name);
            }

            using (var logger = new Program.Logger("Updating mandator ... ", client))
            {
                mandator = await new MandatorPostRequest(mandator.Id, new MandatorUpdateParameter
                {
                    Name = "My new name " + Guid.NewGuid()
                }).LoadResultAsync(client);
                logger.Write("Mandator '{0}' updated.", mandator.Name);
            }

            using (var logger = new Program.Logger("Deleting mandator ... ", client))
            {
                mandator = await new MandatorDeleteRequest(mandator.Id).LoadResultAsync(client);
                logger.Write("Mandator '{0}' deleted.", mandator.Name);
            }
        }