public void Setup() { _eTagProvider = new ETagProvider(); var dateTime = DateTime.Now; _localDateTime = dateTime.ToLocalTime(); _utcDateTime = dateTime.ToUniversalTime(); _unspecifiedDateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified); }
public static void MapTo(this IStudentSchoolAssociation source, IStudentSchoolAssociation target, Action <IStudentSchoolAssociation, IStudentSchoolAssociation> onMapped) { var sourceSynchSupport = source as IStudentSchoolAssociationSynchronizationSourceSupport; var targetSynchSupport = target as IStudentSchoolAssociationSynchronizationSourceSupport; // Copy resource Id target.Id = source.Id; // Copy contextual primary key values target.SchoolName = source.SchoolName; target.StudentFirstName = source.StudentFirstName; target.StudentLastSurname = source.StudentLastSurname; // Copy non-PK properties // Copy Aggregate Reference Data if (GeneratedArtifactStaticDependencies.AuthorizationContextProvider == null || GeneratedArtifactStaticDependencies.AuthorizationContextProvider.GetAction() == RequestActions.ReadActionUri) { target.SchoolResourceId = source.SchoolResourceId; target.SchoolDiscriminator = source.SchoolDiscriminator; target.StudentResourceId = source.StudentResourceId; target.StudentDiscriminator = source.StudentDiscriminator; } // ---------------------------------- // 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); } }
public static void MapTo(this ISchoolAddress source, ISchoolAddress target, Action <ISchoolAddress, ISchoolAddress> onMapped) { var sourceSynchSupport = source as ISchoolAddressSynchronizationSourceSupport; var targetSynchSupport = target as ISchoolAddressSynchronizationSourceSupport; // Copy contextual primary key values // Copy non-PK properties if (sourceSynchSupport.IsCitySupported) { target.City = source.City; } else { targetSynchSupport.IsCitySupported = false; } // 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); } }
public static void MapTo(this IStudentAcademicRecordClassRankingExtension source, IStudentAcademicRecordClassRankingExtension target, Action <IStudentAcademicRecordClassRankingExtension, IStudentAcademicRecordClassRankingExtension> onMapped) { var sourceSynchSupport = source as IStudentAcademicRecordClassRankingExtensionSynchronizationSourceSupport; var targetSynchSupport = target as IStudentAcademicRecordClassRankingExtensionSynchronizationSourceSupport; // Copy contextual primary key values // Copy non-PK properties if (sourceSynchSupport.IsSpecialEducationGraduationStatusDescriptorSupported) { target.SpecialEducationGraduationStatusDescriptor = source.SpecialEducationGraduationStatusDescriptor; } else { targetSynchSupport.IsSpecialEducationGraduationStatusDescriptorSupported = false; } // 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); } }
public static void MapTo(this IName source, IName target, Action <IName, IName> onMapped) { var sourceSynchSupport = source as INameSynchronizationSourceSupport; var targetSynchSupport = target as INameSynchronizationSourceSupport; // Copy resource Id target.Id = source.Id; // Copy contextual primary key values target.FirstName = source.FirstName; target.LastSurname = source.LastSurname; // 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); } }
public static void MapTo(this ISchool source, ISchool target, Action <ISchool, ISchool> onMapped) { var sourceSynchSupport = source as ISchoolSynchronizationSourceSupport; var targetSynchSupport = target as ISchoolSynchronizationSourceSupport; // Copy resource Id target.Id = source.Id; // Copy contextual primary key values target.SchoolName = source.SchoolName; // Copy non-PK properties if (sourceSynchSupport.IsSchoolYearSupported) { target.SchoolYear = source.SchoolYear; } else { targetSynchSupport.IsSchoolYearSupported = false; } // Copy Aggregate Reference Data if (GeneratedArtifactStaticDependencies.AuthorizationContextProvider == null || GeneratedArtifactStaticDependencies.AuthorizationContextProvider.GetAction() == RequestActions.ReadActionUri) { target.SchoolYearTypeResourceId = source.SchoolYearTypeResourceId; target.SchoolYearTypeDiscriminator = source.SchoolYearTypeDiscriminator; } // ---------------------------------- // Map One-to-one relationships // ---------------------------------- // SchoolAddress (Source) if (sourceSynchSupport.IsSchoolAddressSupported) { var itemProperty = target.GetType().GetProperty("SchoolAddress"); if (itemProperty != null) { if (source.SchoolAddress == null) { target.SchoolAddress = null; } else { var itemType = itemProperty.PropertyType; object targetSchoolAddress = Activator.CreateInstance(itemType); (targetSchoolAddress as IChildEntity)?.SetParent(target); source.SchoolAddress.Map(targetSchoolAddress); // Update the target reference appropriately target.SchoolAddress = (ISchoolAddress)targetSchoolAddress; } } } else { targetSynchSupport.IsSchoolAddressSupported = false; } // ------------------------------------------------------------- // 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); } }
public static void MapTo(this IStudentAcademicRecordExtension source, IStudentAcademicRecordExtension target, Action <IStudentAcademicRecordExtension, IStudentAcademicRecordExtension> onMapped) { var sourceSynchSupport = source as IStudentAcademicRecordExtensionSynchronizationSourceSupport; var targetSynchSupport = target as IStudentAcademicRecordExtensionSynchronizationSourceSupport; // Copy contextual primary key values // Copy non-PK properties if (sourceSynchSupport.IsNameOfInstitutionSupported) { target.NameOfInstitution = source.NameOfInstitution; } else { targetSynchSupport.IsNameOfInstitutionSupported = false; } if (sourceSynchSupport.IsSubmissionCertificationDescriptorSupported) { target.SubmissionCertificationDescriptor = source.SubmissionCertificationDescriptor; } else { targetSynchSupport.IsSubmissionCertificationDescriptorSupported = false; } // Copy Aggregate Reference Data if (GeneratedArtifactStaticDependencies.AuthorizationContextProvider == null || GeneratedArtifactStaticDependencies.AuthorizationContextProvider.GetAction() == RequestActions.ReadActionUri) { target.PostSecondaryOrganizationResourceId = source.PostSecondaryOrganizationResourceId; target.PostSecondaryOrganizationDiscriminator = source.PostSecondaryOrganizationDiscriminator; } // ---------------------------------- // 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); } }
public static void MapTo(this IInstitutionControlDescriptor source, IInstitutionControlDescriptor target, Action <IInstitutionControlDescriptor, IInstitutionControlDescriptor> onMapped) { var sourceSynchSupport = source as IInstitutionControlDescriptorSynchronizationSourceSupport; var targetSynchSupport = target as IInstitutionControlDescriptorSynchronizationSourceSupport; // Copy resource Id target.Id = source.Id; // Copy contextual primary key values target.InstitutionControlDescriptorId = source.InstitutionControlDescriptorId; // Copy inherited non-PK properties if (sourceSynchSupport.IsCodeValueSupported) { target.CodeValue = source.CodeValue; } else { targetSynchSupport.IsCodeValueSupported = false; } if (sourceSynchSupport.IsDescriptionSupported) { target.Description = source.Description; } else { targetSynchSupport.IsDescriptionSupported = false; } if (sourceSynchSupport.IsEffectiveBeginDateSupported) { target.EffectiveBeginDate = source.EffectiveBeginDate; } else { targetSynchSupport.IsEffectiveBeginDateSupported = false; } if (sourceSynchSupport.IsEffectiveEndDateSupported) { target.EffectiveEndDate = source.EffectiveEndDate; } else { targetSynchSupport.IsEffectiveEndDateSupported = false; } if (sourceSynchSupport.IsNamespaceSupported) { target.Namespace = source.Namespace; } else { targetSynchSupport.IsNamespaceSupported = false; } if (sourceSynchSupport.IsPriorDescriptorIdSupported) { target.PriorDescriptorId = source.PriorDescriptorId; } else { targetSynchSupport.IsPriorDescriptorIdSupported = false; } if (sourceSynchSupport.IsShortDescriptionSupported) { target.ShortDescription = source.ShortDescription; } else { targetSynchSupport.IsShortDescriptionSupported = false; } // Copy non-PK properties // Copy Aggregate Reference Data // ---------------------------------- // Map One-to-one relationships // ---------------------------------- // Map inherited lists // 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); } }
public static void MapTo(this IPostSecondaryOrganization source, IPostSecondaryOrganization target, Action <IPostSecondaryOrganization, IPostSecondaryOrganization> onMapped) { var sourceSynchSupport = source as IPostSecondaryOrganizationSynchronizationSourceSupport; var targetSynchSupport = target as IPostSecondaryOrganizationSynchronizationSourceSupport; // Copy resource Id target.Id = source.Id; // Copy contextual primary key values target.NameOfInstitution = source.NameOfInstitution; // Copy non-PK properties if (sourceSynchSupport.IsAcceptanceIndicatorSupported) { target.AcceptanceIndicator = source.AcceptanceIndicator; } else { targetSynchSupport.IsAcceptanceIndicatorSupported = false; } if (sourceSynchSupport.IsInstitutionControlDescriptorSupported) { target.InstitutionControlDescriptor = source.InstitutionControlDescriptor; } else { targetSynchSupport.IsInstitutionControlDescriptorSupported = false; } if (sourceSynchSupport.IsInstitutionLevelDescriptorSupported) { target.InstitutionLevelDescriptor = source.InstitutionLevelDescriptor; } else { targetSynchSupport.IsInstitutionLevelDescriptorSupported = false; } // 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); } }
public UsersController(IUserService userService, ETagProvider etag, UserResourceFactory resourceFactory) { _userService = userService ?? throw new ArgumentNullException(nameof(userService)); _etag = etag ?? throw new ArgumentNullException(nameof(etag)); _resourceFactory = resourceFactory ?? throw new ArgumentNullException(nameof(resourceFactory)); }