private void DoUpdate(
     UpdatedEcaAddress updatedAddress,
     Location location,
     Address address,
     ICollection <Address> otherAddresses,
     Location country,
     Location division,
     Location city)
 {
     Contract.Requires(updatedAddress != null, "The updated address must not be null.");
     Contract.Requires(location != null, "The location must not be null.");
     Contract.Requires(address != null, "The address must not be null.");
     logger.Info("Updating the address with id [{0}].", updatedAddress.AddressId);
     addressValidator.ValidateUpdate(ToEcaAddressValidationEntity(address: updatedAddress, country: country, division: division, city: city));
     location.CityId         = updatedAddress.CityId;
     location.CountryId      = updatedAddress.CountryId;
     location.DivisionId     = updatedAddress.DivisionId;
     location.LocationName   = updatedAddress.LocationName;
     location.LocationTypeId = updatedAddress.LocationTypeId;
     location.PostalCode     = updatedAddress.PostalCode;
     location.Street1        = updatedAddress.Street1;
     location.Street2        = updatedAddress.Street2;
     location.Street3        = updatedAddress.Street3;
     address.AddressTypeId   = updatedAddress.AddressTypeId;
     address.IsPrimary       = updatedAddress.IsPrimary;
     updatedAddress.Update.SetHistory(location);
     updatedAddress.Update.SetHistory(address);
     if (updatedAddress.IsPrimary)
     {
         SetAllAddressesNotPrimary(otherAddresses);
     }
 }
        /// <summary>
        /// Updates an existing address.
        /// </summary>
        /// <param name="updatedAddress">The updated address.</param>
        public void Update(UpdatedEcaAddress updatedAddress)
        {
            var address = Context.Addresses.Find(updatedAddress.AddressId);

            throwIfEntityNotFound(updatedAddress.AddressId, address, typeof(Address));
            var location = Context.Locations.Find(address.LocationId);

            Contract.Assert(location != null, "The address must have a location.");
            var city = Context.Locations.Find(updatedAddress.CityId);

            throwIfLocationNotFound(updatedAddress.CityId, city, "City");

            var country = Context.Locations.Find(updatedAddress.CountryId);

            throwIfLocationNotFound(updatedAddress.CountryId, country, "Country");

            Location division = null;

            if (updatedAddress.DivisionId.HasValue)
            {
                division = Context.Locations.Find(updatedAddress.DivisionId.Value);
                throwIfLocationNotFound(updatedAddress.DivisionId.Value, division, "Division");
            }
            var otherAddresses = CreateGetOtherEntityAddressesQuery(address).ToList();

            DoUpdate(updatedAddress: updatedAddress,
                     location: location,
                     address: address,
                     otherAddresses: otherAddresses,
                     country: country,
                     division: division,
                     city: city
                     );
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="updatedAddress"></param>
 /// <returns></returns>
 public Task UpdateAsync(UpdatedEcaAddress updatedAddress)
 {
     Contract.Requires(updatedAddress != null, "The updated address must not be null.");
     return(Task.FromResult <Object>(null));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="updatedAddress"></param>
 public void Update(UpdatedEcaAddress updatedAddress)
 {
     Contract.Requires(updatedAddress != null, "The updated address must not be null.");
 }