示例#1
0
        public async Task AnonymiseCustomerData()
        {
            var customers = await GetAllCustomers();

            var collectionUri = _documentDbHelper.CreateDestinationCustomerDocumentCollectionUri();
            var client        = _databaseClient.CreateDestinationDocumentClient();

            var databaseName       = "customers";
            var databaseCollection = "customers-anonymised";

            client.CreateDocumentCollectionIfNotExistsAsync(
                UriFactory.CreateDatabaseUri(databaseName),
                new DocumentCollection {
                Id = databaseCollection
            }).
            GetAwaiter()
            .GetResult();

            foreach (var cust in customers)
            {
                cust.FamilyName  = _utils.RandomString() + cust.FamilyName + _utils.RandomString();
                cust.GivenName   = _utils.RandomString() + cust.GivenName + _utils.RandomString();
                cust.DateofBirth = _utils.RandomDate();
                var response = await client.CreateDocumentAsync(collectionUri, cust);
            }
        }