public static bool SynchronizeTo(this IStaffAddress source, IStaffAddress target) { bool isModified = false; var sourceSupport = source as IStaffAddressSynchronizationSourceSupport; // Back synch non-reference portion of PK (PK properties cannot be changed, therefore they can be omitted in the resource payload, but we need them for proper comparisons for persistence) if (source.City != target.City) { source.City = target.City; } // Copy non-PK properties // Sync lists return(isModified); }
public static void MapTo(this IStaffAddress source, IStaffAddress target, Action <IStaffAddress, IStaffAddress> onMapped) { var sourceSynchSupport = source as IStaffAddressSynchronizationSourceSupport; var targetSynchSupport = target as IStaffAddressSynchronizationSourceSupport; // Copy contextual primary key values target.City = source.City; // Copy non-PK properties // Copy Aggregate Reference Data // ---------------------------------- // Map One-to-one relationships // ---------------------------------- // Map lists var eTagProvider = new ETagProvider(); // Convert value to ETag, if appropriate var entityWithETag = target as IHasETag; if (entityWithETag != null) { entityWithETag.ETag = eTagProvider.GetETag(source); } // Convert value to LastModifiedDate, if appropriate var dateVersionedEntity = target as IDateVersionedEntity; var etagSource = source as IHasETag; if (dateVersionedEntity != null && etagSource != null) { dateVersionedEntity.LastModifiedDate = eTagProvider.GetDateTime(etagSource.ETag); } }