public static async Task <APUser> CreateNewUserAsync(APUser user = null, bool returnPassword = true) { // Create user user = user ?? new APUser() { Username = "******" + Unique.String, // ensure unique user name Email = "john.doe@" + Unique.String + ".com", // unique but useless email address Password = "******", DateOfBirth = DateTime.Today.AddYears(-25), FirstName = "John", LastName = "Doe", Phone = "987-654-3210", Location = new Geocode(18, 19) }; Console.WriteLine("Creating new user with username {0}.", user.Username); var createRequest = new CreateUserRequest() { User = user }; var createResponse = await createRequest.ExecuteAsync(); var created = createResponse.User; Assert.IsNotNull(created, "Initial user creation failed."); Console.WriteLine("Created new user with username {0} and id {1}.", created.Username, created.Id); // Setup the password if (returnPassword == true) { created.Password = user.Password; } return(created); }
public async Task CreateUserAsyncTest() { var user = new User() { Username = "******" + Unique.String, // ensure unique user name Email = "john.doe@" + Unique.String + ".com", // unique but useless email address Password = "******", DateOfBirth = DateTime.Today.AddYears(-25), FirstName = "John", LastName = "Doe", Phone = "987-654-3210", Location = new Geocode(18, 19) }; // Create user var request = new CreateUserRequest() { User = user }; var response = await request.ExecuteAsync(); ApiHelper.EnsureValidResponse(response); Assert.IsNotNull(response.User, "User in response is null."); Assert.IsTrue(string.IsNullOrWhiteSpace(response.User.Id) == false); Console.WriteLine("Created user with id {0}.", response.User.Id); }
protected override async Task <Entity> CreateNewAsync(ApiOptions options) { var request = new CreateUserRequest() { User = this }; ApiOptions.Apply(request, options); // Create a new object var response = await request.ExecuteAsync(); if (response.Status.IsSuccessful == false) { throw response.Status.ToFault(); } // 3. Update the last known state based on the differences Debug.Assert(response.User != null, "If status is successful, then created user should not be null."); return(response.User); }