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); }
public ProfileUpdateBuilder() { _request = new UpdateAddressAndContactsRequest(); }