public async Task UpdateAddressAndContacts(Action <ProfileUpdateBuilder> setup)
        {
            UpdateAddressAndContactsRequest request =
                setup.CreateTargetAndInvoke().SetServiceConsumer(_settings.Consumer).Build();

            DistributorProfile profile = await GetProfile(request.DistributorId);

            if (request.Address != null)
            {
                DistributorAddress addressToUpdate = profile.Shipping?.Addresses?.FirstOrDefault(x => x.Type.Equals(request.Address.Type, StringComparison.InvariantCultureIgnoreCase));
                if (addressToUpdate != null)
                {
                    request.Address.FillInWithUnspecifiedData(addressToUpdate);
                }
                else
                {
                    request.Address = null;  // We're not allowed to create new address
                }
            }

            if (request.Contact != null)
            {
                DistributorContact contactToUpdate = profile.Shipping?.Contacts?.FirstOrDefault(x => x.Type.Equals(request.Contact.Type, StringComparison.InvariantCultureIgnoreCase));
                if (contactToUpdate != null)
                {
                    request.Contact.FillInWithUnspecifiedData(contactToUpdate);
                }
                else
                {
                    request.Contact = null;  // We're not allowed to create new contact
                }
            }

            object response = await _proxy.UpdateDsAddressContacts.POSTAsync(request);
        }
Пример #2
0
        [InlineData("HERB108388")] // DELETED member state
        public async Task Test_Get_profile(string distributorId)
        {
            // Prepare
            Assert.NotNull(_adapter);

            // Pre-validate
            Assert.False(string.IsNullOrWhiteSpace(distributorId));

            // Perform
            DistributorProfile result = await _adapter.GetProfile(distributorId);

            // Post-validate
            Assert.NotNull(result);
            Assert.Equal(distributorId, result.Id);
        }
Пример #3
0
        public async Task Test_Update_Distributor_address_and_contacts(string distributorId)
        {
            // Prepare
            Assert.NotNull(_adapter);

            // Pre-validate
            Assert.False(string.IsNullOrWhiteSpace(distributorId));

            // Perform
            await _adapter.UpdateAddressAndContacts((b) =>
                                                    b.SetDistributorId(distributorId)
                                                    .SetAddress(addressType : "SHIP_TO", country : "RU", zipCode : "170043", city : "????? ?", addressLines : new string[] { "??????????? ??-??", "??? 95, ??? 4, ?? 159", "", "VALENTINA VASILEVA" }, careOfName : "VALENTINA VASILEVA")
                                                    .SetContacts("PHONE", "90-40239208")
                                                    );

            // Post-validate
            DistributorProfile profile = await _adapter.GetProfile(distributorId);

            // check address & contact match
            //Assert.NotNull(result);
            //Assert.Equal(distributorId, result.Id);
        }