} // public static void MapFromDB(DBEntity input, ThisEntity output, bool gettingAll = true) { output.Id = input.Id; output.RowId = input.RowId; output.EntityStateId = input.EntityStateId; output.Name = input.Name; output.Description = input.Description; output.CTID = input.CTID; if (input.Created != null) { output.Created = ( DateTime )input.Created; } if (input.LastUpdated != null) { output.LastUpdated = ( DateTime )input.LastUpdated; } if (IsGuidValid(input.OwningAgentUid)) { output.OwningAgentUid = ( Guid )input.OwningAgentUid; output.OwningOrganization = OrganizationManager.GetForSummary(output.OwningAgentUid); //get roles OrganizationRoleProfile orp = Entity_AgentRelationshipManager.AgentEntityRole_GetAsEnumerationFromCSV(output.RowId, output.OwningAgentUid); output.OwnerRoles = orp.AgentRole; } // output.OrganizationRole = Entity_AgentRelationshipManager.AgentEntityRole_GetAll_ToEnumeration(output.RowId, true); // //get related .... var relatedEntity = EntityManager.GetEntity(output.RowId, false); if (relatedEntity != null && relatedEntity.Id > 0) { output.EntityLastUpdated = relatedEntity.LastUpdated; } // output.SubjectWebpage = input.SubjectWebpage; output.CredentialRegistryId = input.CredentialRegistryId ?? ""; output.LifecycleStatusType = string.IsNullOrWhiteSpace(input.LifecycleStatusType) ? "lifecycle:Active" : input.LifecycleStatusType; //output.CodedNotation = input.CodedNotation; //20-12-16 changed to a string as partial dates are possible if (!string.IsNullOrWhiteSpace(input.StartDate)) { output.StartDate = input.StartDate; } else { output.StartDate = ""; } // if (!string.IsNullOrWhiteSpace(input.EndDate)) { output.EndDate = input.EndDate; } else { output.EndDate = ""; } //derived from .... //get json and expand output.IdentifierJson = input.IdentifierJson; output.TransferValueJson = input.TransferValueJson; output.TransferValueFromJson = input.TransferValueFromJson; output.TransferValueForJson = input.TransferValueForJson; // if (!string.IsNullOrWhiteSpace(output.IdentifierJson)) { output.Identifier = JsonConvert.DeserializeObject <List <Entity_IdentifierValue> >(output.IdentifierJson); } if (!string.IsNullOrWhiteSpace(output.TransferValueJson)) { output.TransferValue = JsonConvert.DeserializeObject <List <ValueProfile> >(output.TransferValueJson); } if (!gettingAll) { return; } //the top level object may not be enough. First need to confirm if reference lopps and asmts can have detail pages. if (!string.IsNullOrWhiteSpace(output.TransferValueFromJson)) { output.TransferValueFrom = JsonConvert.DeserializeObject <List <TopLevelObject> >(output.TransferValueFromJson); var lopps = output.TransferValueFrom.Where(s => s.EntityTypeId == 7).ToList(); foreach (var item in lopps) { output.TransferValueFromLopp.Add(LearningOpportunityManager.GetForDetail(item.Id)); } var assmts = output.TransferValueFrom.Where(s => s.EntityTypeId == 3).ToList(); foreach (var item in assmts) { output.TransferValueFromAsmt.Add(AssessmentManager.GetForDetail(item.Id)); } var creds = output.TransferValueFrom.Where(s => s.EntityTypeId == 1).ToList(); foreach (var item in creds) { output.TransferValueFromCredential.Add(CredentialManager.GetForDetail(item.Id)); } } // if (!string.IsNullOrWhiteSpace(output.TransferValueForJson)) { output.TransferValueFor = JsonConvert.DeserializeObject <List <TopLevelObject> >(output.TransferValueForJson); var lopps = output.TransferValueFor.Where(s => s.EntityTypeId == 7).ToList(); foreach (var item in lopps) { output.TransferValueForLopp.Add(LearningOpportunityManager.GetForDetail(item.Id)); } var assmts = output.TransferValueFor.Where(s => s.EntityTypeId == 3).ToList(); foreach (var item in assmts) { output.TransferValueForAsmt.Add(AssessmentManager.GetForDetail(item.Id)); } var creds = output.TransferValueFor.Where(s => s.EntityTypeId == 1).ToList(); foreach (var item in creds) { output.TransferValueForCredential.Add(CredentialManager.GetForDetail(item.Id)); } } //this should be a summary level, not the full TVP output.DerivedFrom = Entity_TransferValueProfileManager.GetAll(output.RowId); // List <ProcessProfile> processes = Entity_ProcessProfileManager.GetAll(output.RowId); foreach (ProcessProfile item in processes) { if (item.ProcessTypeId == Entity_ProcessProfileManager.DEV_PROCESS_TYPE) { output.DevelopmentProcess.Add(item); } else { //unexpected } } }
public static void MapFromDB(DBEntity input, ThisEntity output, bool includingParts) { output.Id = input.Id; output.RowId = input.RowId; output.EntityStateId = input.EntityStateId; output.Description = input.Description == null ? "" : input.Description; output.CTID = input.CTID; output.DataSuppressionPolicy = input.DataSuppressionPolicy; output.SubjectIdentification = input.SubjectIdentification; output.Source = GetUrlData(input.Source); // if (IsGuidValid(input.DataProviderUID)) { output.DataProviderUID = ( Guid )input.DataProviderUID; output.DataProvider = OrganizationManager.GetForSummary(output.DataProviderUID); } // output.InstructionalProgramType = Reference_FrameworksManager.FillEnumeration(output.RowId, CodesManager.PROPERTY_CATEGORY_CIP); // if (input.DistributionFile != null) { var list = input.DistributionFile.Split('|'); foreach (var item in list) { if (!string.IsNullOrWhiteSpace(item)) { output.DistributionFile.Add(item); } } } else { output.DistributionFile = new List <string>(); } // if (IsValidDate(input.Created)) { output.Created = ( DateTime )input.Created; } if (IsValidDate(input.LastUpdated)) { output.LastUpdated = ( DateTime )input.LastUpdated; } if (string.IsNullOrWhiteSpace(output.CTID) || output.EntityStateId < 3) { output.IsReferenceVersion = true; return; } //===== var relatedEntity = EntityManager.GetEntity(output.RowId, false); if (relatedEntity != null && relatedEntity.Id > 0) { output.EntityLastUpdated = relatedEntity.LastUpdated; } //components if (includingParts) { var processProfiles = Entity_ProcessProfileManager.GetAll(input.RowId); foreach (ProcessProfile item in processProfiles) { if (item.ProcessTypeId == Entity_ProcessProfileManager.ADMIN_PROCESS_TYPE) { output.AdministrationProcess.Add(item); } } // output.Jurisdiction = Entity_JurisdictionProfileManager.Jurisdiction_GetAll(output.RowId); //get DataSetTimePeriod output.DataSetTimePeriod = DataSetTimeFrameManager.GetAll(output.Id); } } //