Beispiel #1
0
        private static void MapJurisdictions(ThisEntity input, ref ThisEntityDetail output)
        {
            if (input.Jurisdiction != null && input.Jurisdiction.Any())
            {
                output.Jurisdiction = ServiceHelper.MapJurisdiction(input.Jurisdiction);
            }
            //return if no assertions
            if (input.JurisdictionAssertions == null || !input.JurisdictionAssertions.Any())
            {
                return;
            }
            //TODO - return all in a group or individual?
            //output.JurisdictionAssertion = ServiceHelper.MapJurisdiction( input.JurisdictionAssertions, "OfferedIn" );
            //OR

            var assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_AccreditedBy).ToList();

            if (assertedIn != null && assertedIn.Any())
            {
                output.AccreditedIn = ServiceHelper.MapJurisdiction(assertedIn, "AccreditedIn");
            }
            //
            assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_ApprovedBy).ToList();
            if (assertedIn != null && assertedIn.Any())
            {
                output.ApprovedIn = ServiceHelper.MapJurisdiction(assertedIn, "ApprovedIn");
            }
            //
            assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_OFFERED_BY).ToList();
            if (assertedIn != null && assertedIn.Any())
            {
                output.OfferedIn = ServiceHelper.MapJurisdiction(assertedIn, "OfferedIn");
            }
            //
            assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_RecognizedBy).ToList();
            if (assertedIn != null && assertedIn.Any())
            {
                output.RecognizedIn = ServiceHelper.MapJurisdiction(assertedIn, "RecognizedIn");
            }
            //
            assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_RegulatedBy).ToList();
            if (assertedIn != null && assertedIn.Any())
            {
                output.RegulatedIn = ServiceHelper.MapJurisdiction(assertedIn, "RegulatedIn");
            }
            //
            assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_RenewedBy).ToList();
            if (assertedIn != null && assertedIn.Any())
            {
                output.RenewedIn = ServiceHelper.MapJurisdiction(assertedIn, "RenewedIn");
            }
            //
            assertedIn = input.JurisdictionAssertions.Where(s => s.AssertedInTypeId == Entity_AgentRelationshipManager.ROLE_TYPE_RevokedBy).ToList();
            if (assertedIn != null && assertedIn.Any())
            {
                output.RevokedIn = ServiceHelper.MapJurisdiction(assertedIn, "RevokedIn");
            }
        }
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //no need to get and cache if called from batch import - maybe during day, but likelihood of issues is small?
                if (UtilityManager.GetAppKeyValue("credentialCacheMinutes", 0) > 0)
                {
                    if (System.DateTime.Now.Hour > 7 && System.DateTime.Now.Hour < 18)
                    {
                        GetDetail(entity.Id);
                    }
                }
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("credentialCacheMinutes", 0) > 0)
                {
                    CacheManager.RemoveItemFromCache("credential", entity.Id);
                }

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    ThreadPool.QueueUserWorkItem(UpdateCaches, entity);

                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                else
                {
                    //only update elatic if has apparent relevent changes
                    if (status.UpdateElasticIndex)
                    {
                        new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CREDENTIAL, entity.Id, 1, ref messages);
                    }
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    //check for embedded items
                    //has part
                    AddCredentialsToPendingReindex(entity.HasPartIds);
                    AddCredentialsToPendingReindex(entity.IsPartOfIds);

                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
        public static ThisEntity GetMinimumByCtid(string ctid)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }

            return(EntityMgr.GetMinimumByCtid(ctid));
        }
        public static ThisEntity GetDetailByCtid(string ctid, bool skippingCache = false)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }
            var credential = EntityMgr.GetMinimumByCtid(ctid);

            return(GetDetail(credential.Id, skippingCache));
        }
        public bool DoesEntityExist(string ctid, ref ThisEntity entity)
        {
            bool exists = false;

            entity = EntityServices.GetByCtid(ctid);
            if (entity != null && entity.Id > 0)
            {
                return(true);
            }

            return(exists);
        }
        /// <summary>
        /// Retrieve Credential for compare purposes
        /// - name, description, cred type, education level,
        /// - industries, occupations
        /// - owner role
        /// - duration
        /// - estimated costs
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static ThisEntity GetCredentialForCompare(int id)
        {
            //not clear if checks necessary, as interface only allows selection of those to which the user has access.
            AppUser user = AccountServices.GetCurrentUser();

            LoggingHelper.DoTrace(2, string.Format("GetCredentialForCompare - using new compare get for cred: {0}", id));

            //================================================
            string statusMessage = "";
            string key           = "credentialCompare_" + id.ToString();

            ThisEntity entity = new ThisEntity();

            if (CacheManager.IsCredentialAvailableFromCache(id, key, ref entity))
            {
                //check if user can update the object
                string status = "";
                //if ( !CanUserUpdateCredential( id, user, ref status ) )
                //    entity.CanEditRecord = false;
                return(entity);
            }

            CredentialRequest cr = new CredentialRequest();

            cr.IsCompareRequest();


            DateTime start = DateTime.Now;

            entity = CredentialManager.GetForCompare(id, cr);

            //if ( CanUserUpdateCredential( entity, user, ref statusMessage ) )
            //    entity.CanUserEditEntity = true;

            DateTime end     = DateTime.Now;
            int      elasped = (end - start).Seconds;

            if (elasped > 1)
            {
                CacheManager.AddCredentialToCache(entity, key);
            }

            return(entity);
        } //
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                var detail = GetDetail(entity.Id, false);
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                CacheManager.RemoveItemFromCache("credential", entity.Id);

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    ThreadPool.QueueUserWorkItem(UpdateCaches2, entity);
                    new SearchPendingReindexManager().Add(1, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CREDENTIAL, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    //check for embedded items
                    //has part
                    AddCredentialsToPendingReindex(entity.HasPartIds);
                    AddCredentialsToPendingReindex(entity.IsPartOfIds);

                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
Beispiel #8
0
        private static void MapProcessProfiles(ThisEntity input, ref ThisEntityDetail output)
        {
            if (input.ProcessProfilesSummary != null && input.ProcessProfilesSummary.Any())
            {
                var url = string.Format("detail/ProcessProfile/{0}/", input.RowId.ToString());
                output.ProcessProfiles = new List <AJAXSettings>();
                foreach (var item in input.ProcessProfilesSummary)
                {
                    var ajax = new AJAXSettings()
                    {
                        Label       = item.Name,
                        Description = "",
                        Total       = item.Totals,
                        URL         = externalFinderSiteURL + url + item.Id.ToString(),
                        TestURL     = ServiceHelper.finderApiSiteURL + url + item.Id.ToString(),
                    };
                    //not sure we need this as part of the URL
                    var qd = new ProcessProfileAjax()
                    {
                        Id            = input.RowId.ToString(),
                        ProcessTypeId = item.Id,
                        //EndPoint = externalFinderSiteURL + url + item.Id.ToString()
                    };
                    ajax.QueryData = qd;

                    /*need to know
                     * endpoint: detail/processprofile
                     * id:		 input.RowId
                     * processProfileTypeId: item.Id?
                     *
                     */
                    //var filter = ( new MD.LabelLink()
                    //{
                    //	Label = item.Name,
                    //	Count = item.Totals,
                    //	URL = externalFinderSiteURL + url + item.Id.ToString()
                    //} );


                    output.ProcessProfiles.Add(ajax);
                }

                return;
            }

            //process profiles
            if (input.AdministrationProcess.Any())
            {
                output.AdministrationProcess = ServiceHelper.MapAJAXProcessProfile("Administration Process", "", input.AdministrationProcess);
            }
            if (input.AppealProcess.Any())
            {
                output.AppealProcess = ServiceHelper.MapAJAXProcessProfile("Appeal Process", "", input.AppealProcess);
            }
            if (input.ComplaintProcess.Any())
            {
                output.ComplaintProcess = ServiceHelper.MapAJAXProcessProfile("Complaint Process", "", input.ComplaintProcess);
            }
            if (input.DevelopmentProcess.Any())
            {
                output.DevelopmentProcess = ServiceHelper.MapAJAXProcessProfile("Development Process", "", input.DevelopmentProcess);
            }
            if (input.MaintenanceProcess.Any())
            {
                output.MaintenanceProcess = ServiceHelper.MapAJAXProcessProfile("Maintenance Process", "", input.MaintenanceProcess);
            }
            if (input.ReviewProcess.Any())
            {
                output.ReviewProcess = ServiceHelper.MapAJAXProcessProfile("Review Process", "", input.ReviewProcess);
            }
            if (input.RevocationProcess.Any())
            {
                output.RevocationProcess = ServiceHelper.MapAJAXProcessProfile("Revocation Process", "", input.RevocationProcess);
            }
        }
Beispiel #9
0
        private static WMA.CredentialDetail MapToAPI(ThisEntity input)
        {
            var output = new WMA.CredentialDetail()
            {
                Meta_Id               = input.Id,
                CTID                  = input.CTID,
                Name                  = input.Name,
                Description           = input.Description,
                SubjectWebpage        = input.SubjectWebpage,
                EntityTypeId          = 1,
                CTDLTypeLabel         = input.CredentialType,
                CTDLType              = input.CredentialTypeSchema,
                CredentialRegistryURL = RegistryServices.GetResourceUrl(input.CTID),
                RegistryData          = ServiceHelper.FillRegistryData(input.CTID)
            };

            //
            //output.CTDLType = record.CredentialType; ;
            //output.AgentSectorType = ServiceHelper.MapPropertyLabelLinks( org.AgentSectorType, "organization" );
            output.FriendlyName  = HttpUtility.UrlPathEncode(input.Name);
            output.AlternateName = input.AlternateName;

            //owned by and offered by
            //need a label link for header
            if (input.OwningOrganizationId > 0)
            {
                output.OwnedByLabel = ServiceHelper.MapDetailLink("Organization", input.OrganizationName, input.OwningOrganizationId);
            }
            var work = ServiceHelper.MapOrganizationRoleProfileToOutline(input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OWNER);

            output.OwnedBy = ServiceHelper.MapOutlineToAJAX(work, "");
            //
            work             = ServiceHelper.MapOrganizationRoleProfileToOutline(input.OrganizationRole, Entity_AgentRelationshipManager.ROLE_TYPE_OFFERED_BY);
            output.OfferedBy = ServiceHelper.MapOutlineToAJAX(work, "Offered by {0} Organization(s)");
            //

            //QA for owner,not offerer
            if (input.OwningOrganization != null && input.OwningOrganization.Id > 0)
            {
                if (input.OwningOrganization.OrganizationRole_Recipient != null && input.OwningOrganization.OrganizationRole_Recipient.Any())
                {
                    output.OwnerQAReceived = ServiceHelper.MapQAReceived(input.OwningOrganization.OrganizationRole_Recipient, searchType);
                }
                //var inheritedRoles = SetupRoles( roleSet.ActingAgent.OrganizationRole_Recipient, loadedAgentIDs );
                //wrapper.QAFromOwner = inheritedRoles.QADirect;
            }
            //
            output.Meta_LastUpdated = input.EntityLastUpdated;
            output.Meta_StateId     = input.EntityStateId;
            output.EntityTypeId     = input.EntityTypeId;
            if (input.InLanguageCodeList != null && input.InLanguageCodeList.Any())
            {
                //output.Meta_Language = input.InLanguageCodeList[ 0 ].TextTitle;
                output.InLanguage = new List <string>();
                foreach (var item in input.InLanguageCodeList)
                {
                    output.InLanguage.Add(item.TextTitle);
                }
            }
            try
            {
                if (input.HasVerificationType_Badge)
                {
                    output.CTDLTypeLabel += " + Badge Issued";
                }
                output.Image = input.Image;
                //
                if (!string.IsNullOrWhiteSpace(input.AvailabilityListing))
                {
                    output.AvailabilityListing = new List <string>()
                    {
                        input.AvailabilityListing
                    }
                }
                ;
                if (!string.IsNullOrWhiteSpace(input.AvailableOnlineAt))
                {
                    output.AvailableOnlineAt = new List <string>()
                    {
                        input.AvailableOnlineAt
                    }
                }
                ;

                if (input.CopyrightHolderOrganization != null && input.CopyrightHolderOrganization.Any())
                {
                    output.CopyrightHolder = new List <WMA.Outline>();
                    //output.CopyrightHolder2 = new List<WMA.LabelLink>();
                    foreach (var target in input.CopyrightHolderOrganization)
                    {
                        if (target != null && target.Id > 0)
                        {
                            //TODO - add overload to only get minimum data - like Link
                            output.CopyrightHolder.Add(ServiceHelper.MapToOutline(target, "organization"));

                            //var link = ServiceHelper.MapDetailLink( "organization", target.Name, target.Id );
                            //output.CopyrightHolder2.Add( link );
                        }
                    }
                    //or Link objects
                }

                output.CredentialStatusType = ServiceHelper.MapPropertyLabelLink(input.CredentialStatusType, searchType);
                output.CredentialType       = ServiceHelper.MapPropertyLabelLink(input.CredentialTypeEnum, searchType);

                output.DateEffective     = input.DateEffective;
                output.ExpirationDate    = input.ExpirationDate;
                output.EstimatedDuration = ServiceHelper.MapDurationProfiles(input.EstimatedDuration);
                output.RenewalFrequency  = ServiceHelper.MapDurationItem(input.RenewalFrequency);
                //
                if (input.DegreeConcentration != null && input.DegreeConcentration.Any())
                {
                    output.DegreeConcentration = ServiceHelper.MapPropertyLabelLinks(input.DegreeConcentration, searchType);
                }
                if (input.DegreeMajor != null && input.DegreeMajor.Any())
                {
                    output.DegreeMajor = ServiceHelper.MapPropertyLabelLinks(input.DegreeMajor, searchType);
                }
                if (input.DegreeMinor != null && input.DegreeMinor.Any())
                {
                    output.DegreeMinor = ServiceHelper.MapPropertyLabelLinks(input.DegreeMinor, searchType);
                }
                //
                if (input.EmbeddedCredentials != null && input.EmbeddedCredentials.Any())
                {
                    output.HasPart2 = new List <WMA.Outline>();
                    foreach (var target in input.EmbeddedCredentials)
                    {
                        if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                        {
                            output.HasPart2.Add(ServiceHelper.MapToOutline(target, searchType));
                        }
                    }
                    output.HasPart  = ServiceHelper.MapOutlineToAJAX(output.HasPart2, "Includes {0} Credential(s)");
                    output.HasPart2 = null;
                }
                //
                if (input.IsPartOf != null && input.IsPartOf.Any())
                {
                    output.IsPartOf2 = new List <WMA.Outline>();
                    foreach (var target in input.IsPartOf)
                    {
                        if (target != null && !string.IsNullOrWhiteSpace(target.Name))
                        {
                            output.IsPartOf2.Add(ServiceHelper.MapToOutline(target, searchType));
                        }
                    }
                    output.IsPartOf  = ServiceHelper.MapOutlineToAJAX(output.IsPartOf2, "Is Part of {0} Credential(s)");
                    output.IsPartOf2 = null;
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 1, Name: {0}, Id: [1}", input.Name, input.Id));
            }

            //addresses
            //MapAddress( input, ref output );
            output.AvailableAt = ServiceHelper.MapAddress(input.Addresses);

            //
            output.Image = input.Image;
            if (!string.IsNullOrWhiteSpace(input.CredentialTypeSchema))
            {
                output.Meta_Icon = WorkITSearchServices.GetCredentialIcon(input.CredentialTypeSchema.ToLower());
            }
            //
            output.IndustryType             = ServiceHelper.MapReferenceFrameworkLabelLink(input.IndustryType, searchType, CodesManager.PROPERTY_CATEGORY_NAICS);
            output.OccupationType           = ServiceHelper.MapReferenceFrameworkLabelLink(input.OccupationType, searchType, CodesManager.PROPERTY_CATEGORY_SOC);
            output.InstructionalProgramType = ServiceHelper.MapReferenceFrameworkLabelLink(input.InstructionalProgramType, searchType, CodesManager.PROPERTY_CATEGORY_CIP);
            //
            output.IsReferenceVersion = input.IsReferenceVersion;
            //
            if (input.Keyword != null && input.Keyword.Any())
            {
                output.Keyword = ServiceHelper.MapPropertyLabelLinks(input.Keyword, searchType);
            }
            if (input.Subject != null && input.Subject.Any())
            {
                output.Subject = ServiceHelper.MapPropertyLabelLinks(input.Subject, searchType);
            }
            //
            output.AssessmentDeliveryType = ServiceHelper.MapPropertyLabelLinks(input.AssessmentDeliveryType, searchType);
            output.AudienceLevelType      = ServiceHelper.MapPropertyLabelLinks(input.AudienceLevelType, searchType);
            output.AudienceType           = ServiceHelper.MapPropertyLabelLinks(input.AudienceType, searchType);
            output.LearningDeliveryType   = ServiceHelper.MapPropertyLabelLinks(input.LearningDeliveryType, searchType);

            //
            //condition profiles
            try
            {
                output.Corequisite = ServiceHelper.MapToConditionProfiles(input.Corequisite, searchType);
                output.Recommends  = ServiceHelper.MapToConditionProfiles(input.Recommends, searchType);
                output.Renewal     = ServiceHelper.MapToConditionProfiles(input.Renewal, searchType);
                output.Requires    = ServiceHelper.MapToConditionProfiles(input.Requires, searchType);
                if (input.CommonConditions != null && input.CommonConditions.Any())
                {
                    //these will likely just be mapped to specific conditions
                    output.CommonConditions = ServiceHelper.MapConditionManifests(input.CommonConditions, searchType);
                    if (output.CommonConditions != null && output.CommonConditions.Any())
                    {
                        foreach (var item in output.CommonConditions)
                        {
                            if (item.Requires != null && item.Requires.Any())
                            {
                                output.Requires = AppendConditions(item.Requires, output.Requires);
                            }
                            if (item.Recommends != null && item.Recommends.Any())
                            {
                                output.Recommends = AppendConditions(item.Recommends, output.Recommends);
                            }
                            if (item.Corequisite != null && item.Corequisite.Any())
                            {
                                output.Corequisite = AppendConditions(item.Requires, output.Corequisite);
                            }
                            if (item.Renewal != null && item.Renewal.Any())
                            {
                                output.Renewal = AppendConditions(item.Renewal, output.Renewal);
                            }
                        }
                    }
                }
                //connection profiles
                if (input.CredentialConnections != null && input.CredentialConnections.Any())
                {
                    //var list = input.CredentialConnections.Where( s => s.ConditionSubTypeId == 2 && s.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_AdvancedStandingFor ).ToList();
                    //foreach ( var item in input.CredentialConnections )
                    //{
                    //	//some default for 1??
                    //	if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_AdvancedStandingFor )
                    //		input.IsAdvancedStandingFor.Add( item );
                    //	else if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_AdvancedStandingFrom )
                    //		input.AdvancedStandingFrom.Add( item );
                    //	else if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_PreparationFor )
                    //		input.IsPreparationFor.Add( item );
                    //	else if ( item.ConditionSubTypeId == 2 && item.ConnectionProfileTypeId == Entity_ConditionProfileManager.ConnectionProfileType_PreparationFrom )
                    //		input.PreparationFrom.Add( item );
                    //	{
                    //		//????;
                    //	}


                    //}
                }
                output.AdvancedStandingFrom  = ServiceHelper.MapToConditionProfiles(input.AdvancedStandingFrom, searchType);
                output.IsAdvancedStandingFor = ServiceHelper.MapToConditionProfiles(input.IsAdvancedStandingFor, searchType);
                //
                output.PreparationFrom  = ServiceHelper.MapToConditionProfiles(input.PreparationFrom, searchType);
                output.IsPreparationFor = ServiceHelper.MapToConditionProfiles(input.IsPreparationFor, searchType);
                //
                output.IsRequiredFor    = ServiceHelper.MapToConditionProfiles(input.IsRequiredFor, searchType);
                output.IsRecommendedFor = ServiceHelper.MapToConditionProfiles(input.IsRecommendedFor, searchType);
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 2, Name: {0}, Id: [1}", input.Name, input.Id));
            }
            //====================================
            //the following can be made a common method
            var dataMergedRequirements    = new MergedConditions();
            var dataMergedRecommendations = new MergedConditions();
            var dataConnections           = new ConnectionData();

            ServiceHelper.GetAllChildren(dataMergedRequirements, dataMergedRecommendations, dataConnections, input, null, null);
            //now pull out estimated durations
            if (dataMergedRequirements.TargetCredential != null && dataMergedRequirements.TargetCredential.Any())
            {
                output.CredentialEstimatedDuration = ServiceHelper.GetAllDurations(dataMergedRequirements.CredentialsSansSelf(input.Id), "Estimated Time to Complete Required Embedded Credentials");
            }
            if (dataMergedRequirements.TargetAssessment != null && dataMergedRequirements.TargetAssessment.Any())
            {
                //output.AssessmentEstimatedDuration = ServiceHelper.GetAllDurationsOLD( dataMergedRequirements.TargetAssessment, "Estimated Time to Complete Required Assessments" );
                output.AssessmentEstimatedDuration = ServiceHelper.GetAllDurations(dataMergedRequirements.TargetAssessment, "Estimated Time to Complete Required Assessments");
            }
            if (dataMergedRequirements.TargetLearningOpportunity != null && dataMergedRequirements.TargetLearningOpportunity.Any())
            {
                output.LearningOpportunityEstimatedDuration = ServiceHelper.GetAllDurations(dataMergedRequirements.TargetLearningOpportunity, "Estimated Time to Complete Required Learning Opportunities");
            }


            //competencies
            var dataAllCompetencies = ServiceHelper.GetAllCompetencies(dataMergedRequirements);

            var allCompetencies = dataAllCompetencies.RequiresByFramework
                                  .Concat(dataAllCompetencies.AssessesByFramework)
                                  .Concat(dataAllCompetencies.TeachesByFramework)
                                  .ToList();
            var allFrameWorks = new Dictionary <string, List <string> >();

            foreach (var frameWork in allCompetencies)
            {
                if (!string.IsNullOrWhiteSpace(frameWork.CaSSViewerUrl) && !allFrameWorks.ContainsKey(frameWork.CaSSViewerUrl ?? ""))
                {
                    allFrameWorks.Add(frameWork.CaSSViewerUrl, frameWork.Items.Select(m => m.TargetNode).ToList());
                }
            }
            var frameworkGraphs = new List <string>();

            foreach (var framework in allCompetencies)
            {
                var uri = (framework.FrameworkUri ?? "").Replace("/resources/", "/graph/");
                if (framework.IsARegistryFrameworkUrl && framework.ExistsInRegistry)
                {
                    var frameworkData = RegistryServices.GetRegistryData("", uri);
                    if (!string.IsNullOrWhiteSpace(frameworkData) && frameworkData.IndexOf("<") != 0)                           //Avoid empty results and results like "<h2>Incomplete response received from application</h2>"
                    {
                        frameworkGraphs.Add(frameworkData);
                    }
                }
            }

            if (dataAllCompetencies.RequiresByFramework.Count() > 0)
            {
            }
            if (dataAllCompetencies.AssessesByFramework.Count() > 0)
            {
            }
            if (dataAllCompetencies.TeachesByFramework.Count() > 0)
            {
            }
            //=======================================
            try
            {
                //
                if (input.CommonCosts != null && input.CommonCosts.Any())
                {
                    output.CommonCosts   = ServiceHelper.MapCostManifests(input.CommonCosts, searchType);
                    output.EstimatedCost = new List <Models.Elastic.CostProfile>();
                    foreach (var item in output.CommonCosts)
                    {
                        output.EstimatedCost.AddRange(item.EstimatedCost);
                    }
                    output.CommonCosts = null;
                }

                if (input.EstimatedCost != null && input.EstimatedCost.Any())
                {
                    if (output.EstimatedCost == null)
                    {
                        output.EstimatedCost = new List <Models.Elastic.CostProfile>();
                    }

                    var estimatedCost = ServiceHelper.MapCostProfiles(input.EstimatedCost, searchType);
                    if (estimatedCost != null && estimatedCost.Any())
                    {
                        output.EstimatedCost.AddRange(estimatedCost);
                    }
                }
                //loop costs
                if (input.Requires.SelectMany(x => x.TargetLearningOpportunity.Where(y => y.EstimatedCost.Count() + y.CommonCosts.Count() > 0)).Count() > 0)
                {
                    var list = input.Requires.SelectMany(x => x.TargetLearningOpportunity).ToList();
                    foreach (var item in list)
                    {
                        if (item.CommonCosts.Any() || item.EstimatedCost.Any())
                        {
                            var commonCosts = ServiceHelper.MapCostManifests(item.CommonCosts, searchType);
                            output.LearningOpportunityCost = new List <Models.Elastic.CostProfile>();
                            if (commonCosts != null && commonCosts.Any())
                            {
                                foreach (var cc in commonCosts)
                                {
                                    output.LearningOpportunityCost.AddRange(cc.EstimatedCost);
                                }
                            }
                        }
                        //
                        if (item.EstimatedCost != null && item.EstimatedCost.Any())
                        {
                            if (output.LearningOpportunityCost == null)
                            {
                                output.LearningOpportunityCost = new List <Models.Elastic.CostProfile>();
                            }

                            var estimatedCost = ServiceHelper.MapCostProfiles(item.EstimatedCost, searchType);
                            if (estimatedCost != null && estimatedCost.Any())
                            {
                                output.LearningOpportunityCost.AddRange(estimatedCost);
                            }
                        }
                    }
                }
                //asmt costs
                if (input.Requires.SelectMany(x => x.TargetAssessment.Where(y => y.EstimatedCost.Count() + y.CommonCosts.Count() > 0)).Count() > 0)
                {
                    var list = input.Requires.SelectMany(x => x.TargetAssessment).ToList();
                    foreach (var item in list)
                    {
                        if (item.CommonCosts.Any() || item.EstimatedCost.Any())
                        {
                            var commonCosts = ServiceHelper.MapCostManifests(item.CommonCosts, searchType);
                            output.AssessmentCost = new List <Models.Elastic.CostProfile>();
                            if (commonCosts != null && commonCosts.Any())
                            {
                                foreach (var cc in commonCosts)
                                {
                                    output.AssessmentCost.AddRange(cc.EstimatedCost);
                                }
                            }
                        }
                        //
                        if (item.EstimatedCost.Any() || item.EstimatedCost.Any())
                        {
                            if (output.AssessmentCost == null)
                            {
                                output.AssessmentCost = new List <Models.Elastic.CostProfile>();
                            }

                            var estimatedCost = ServiceHelper.MapCostProfiles(item.EstimatedCost, searchType);
                            if (estimatedCost != null && estimatedCost.Any())
                            {
                                output.AssessmentCost.AddRange(estimatedCost);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 3, Name: {0}, Id: [1}", input.Name, input.Id));
            }


            //
            if (input.FinancialAssistance != null && input.FinancialAssistance.Any())
            {
                output.FinancialAssistance = ServiceHelper.MapFinancialAssistanceProfiles(input.FinancialAssistance, searchType);
            }
            //
            output.CredentialId = input.CredentialId;
            output.ISICV4       = input.ISICV4;
            //InLanguage

            //
            output.Identifier = ServiceHelper.MapIdentifierValue(input.Identifier);
            //
            MapProcessProfiles(input, ref output);
            output.SameAs = ServiceHelper.MapTextValueProfileTextValue(input.SameAs);
            //
            //output.ProcessStandards = input.ProcessStandards;
            //output.ProcessStandardsDescription = input.ProcessStandardsDescription;
            output.ProcessStandards = ServiceHelper.MapPropertyLabelLink(input.ProcessStandards, "Process Standards", input.ProcessStandardsDescription);

            //
            output.Revocation = ServiceHelper.MapRevocationProfile(searchType, input.Revocation);

            //these are can be links to existing credentials, likely to be in finder
            output.LatestVersion   = ServiceHelper.MapPropertyLabelLink(input.LatestVersion, "Latest Version");
            output.NextVersion     = ServiceHelper.MapPropertyLabelLink(input.NextVersion, "Next Version");
            output.PreviousVersion = ServiceHelper.MapPropertyLabelLink(input.PreviousVersion, "Previous Version");
            output.Supersedes      = ServiceHelper.MapPropertyLabelLink(input.Supersedes, "Supersedes");
            output.SupersededBy    = ServiceHelper.MapPropertyLabelLink(input.SupersededBy, "Superseded By");
            //
            output.TargetPathway = ServiceHelper.MapPathwayToAJAXSettings(input.TargetPathway, "Has {0} Target Pathway(s)");

            //
            output.VersionIdentifier = ServiceHelper.MapIdentifierValue(input.VersionIdentifierList, "Version Identifier");
            try
            {
                MapJurisdictions(input, ref output);
                //
                //QA received
                //==> need to exclude 30-published by
                if (input.OrganizationRole.Any())
                {
                    output.QAReceived = ServiceHelper.MapQAReceived(input.OrganizationRole, searchType);
                    //old
                    var renewedBy2 = ServiceHelper.MapRoleReceived(input.OrganizationRole, searchType, Entity_AgentRelationshipManager.ROLE_TYPE_RenewedBy);
                    var revokedBy2 = ServiceHelper.MapRoleReceived(input.OrganizationRole, searchType, Entity_AgentRelationshipManager.ROLE_TYPE_RevokedBy);
                    //new
                    output.RenewedBy = ServiceHelper.MapOutlineToAJAX(renewedBy2, "Renewed by {0} Organization(s)");
                    output.RevokedBy = ServiceHelper.MapOutlineToAJAX(revokedBy2, "Revoked by {0} Organization(s)");
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format(thisClassName + ".MapToAPI. Section 4, Name: {0}, Id: [1}", input.Name, input.Id));
            }
            //



            //
            return(output);
        }
        /// <summary>
        /// Get a credential for detailed display
        /// </summary>
        /// <param name="id"></param>
        /// <param name="user"></param>
        /// <param name="skippingCache">If true, do not use the cached version</param>
        /// <returns></returns>
        public static ThisEntity GetDetail(int id, CredentialRequest cr, bool skippingCache = false)
        {
            //
            string   statusMessage = "";
            int      cacheMinutes  = UtilityManager.GetAppKeyValue("credentialCacheMinutes", 0);
            DateTime maxTime       = DateTime.Now.AddMinutes(cacheMinutes * -1);

            string key = "credential_" + id.ToString();

            if (skippingCache == false &&
                HttpRuntime.Cache[key] != null && cacheMinutes > 0)
            {
                var cache = ( CachedCredential )HttpRuntime.Cache[key];
                try
                {
                    if (cache.LastUpdated > maxTime)
                    {
                        LoggingHelper.DoTrace(6, string.Format("===CredentialServices.GetCredentialDetail === Using cached version of Credential, Id: {0}, {1}", cache.Item.Id, cache.Item.Name));

                        return(cache.Item);
                    }
                }
                catch (Exception ex)
                {
                    LoggingHelper.DoTrace(6, "===CredentialServices.GetCredentialDetail === exception " + ex.Message);
                }
            }
            else
            {
                LoggingHelper.DoTrace(8, string.Format("****** CredentialServices.GetCredentialDetail === Retrieving full version of credential, Id: {0}", id));
            }

            DateTime start = DateTime.Now;

            //CredentialRequest cr = new CredentialRequest();
            //cr.IsDetailRequest();

            ThisEntity entity = CredentialManager.GetForDetail(id, cr);

            DateTime end     = DateTime.Now;
            var      elasped = end.Subtract(start).TotalSeconds;

            //Cache the output if more than specific seconds,
            //NOTE need to be able to force it for imports
            //&& elasped > 2
            if (key.Length > 0 && cacheMinutes > 0)
            {
                var newCache = new CachedCredential()
                {
                    Item        = entity,
                    LastUpdated = DateTime.Now
                };
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Cache[key] != null)
                    {
                        HttpRuntime.Cache.Remove(key);
                        HttpRuntime.Cache.Insert(key, newCache);

                        LoggingHelper.DoTrace(5, string.Format("===CredentialServices.GetCredentialDetail $$$ Updating cached version of credential, Id: {0}, {1}", entity.Id, entity.Name));
                    }
                    else
                    {
                        LoggingHelper.DoTrace(5, string.Format("===CredentialServices.GetCredentialDetail ****** Inserting new cached version of credential, Id: {0}, {1}", entity.Id, entity.Name));

                        System.Web.HttpRuntime.Cache.Insert(key, newCache, null, DateTime.Now.AddMinutes(cacheMinutes), TimeSpan.Zero);
                    }
                }
            }
            else
            {
                LoggingHelper.DoTrace(7, string.Format("===CredentialServices.GetCredentialDetail $$$$$$ skipping caching of credential, Id: {0}, {1}, elasped:{2}", entity.Id, entity.Name, elasped));
            }

            return(entity);
        }
        public bool ImportV3(string payload, string envelopeIdentifier, SaveStatus status)
        {
            //instantiate the input document (credential)
            InputEntityV3 input      = new InputEntityV3();
            var           bnodes     = new List <BNode>();
            var           mainEntity = new Dictionary <string, object>();
            //map payload to a dictionary
            Dictionary <string, object> dictionary = RegistryServices.JsonToDictionary(payload);
            //get the @graph property
            object graph = dictionary["@graph"];
            //serialize the graph object
            var glist = JsonConvert.SerializeObject(graph);

            //parse graph in to list of objects
            JArray graphList = JArray.Parse(glist);
            int    cntr      = 0;

            foreach (var item in graphList)
            {
                cntr++;
                if (cntr == 1)
                {
                    var main = item.ToString();
                    //may not use this. Could add a trace method
                    //mainEntity = RegistryServices.JsonToDictionary( main );
                    input = JsonConvert.DeserializeObject <InputEntityV3>(main);
                }
                else
                {
                    //save blank nodes - typically reference organizations
                    var bn = item.ToString();
                    bnodes.Add(JsonConvert.DeserializeObject <BNode>(bn));
                }
            }

            List <string>   messages          = new List <string>();
            bool            importSuccessfull = false;
            EntityServices  mgr    = new EntityServices();
            MappingHelperV3 helper = new MappingHelperV3();

            helper.entityBlankNodes = bnodes;

            status.EnvelopeId = envelopeIdentifier;
            try
            {
                //input = JsonConvert.DeserializeObject<InputEntity>( item.DecodedResource.ToString() );
                string ctid           = input.Ctid;
                string referencedAtId = input.CtdlId;

                LoggingHelper.DoTrace(5, "		name: "+ input.Name.ToString());
                LoggingHelper.DoTrace(6, "		url: "+ input.SubjectWebpage);
                LoggingHelper.DoTrace(5, "		ctid: "+ input.Ctid);
                LoggingHelper.DoTrace(6, "		@Id: "+ input.CtdlId);
                status.Ctid = ctid;

                if (status.DoingDownloadOnly)
                {
                    return(true);
                }

                if (!DoesEntityExist(input.Ctid, ref output))
                {
                    //set the rowid now, so that can be referenced as needed
                    output.RowId = Guid.NewGuid();
                }
                helper.currentBaseObject = output;

                //start with language and may use with language maps
                foreach (var l in input.InLanguage)
                {
                    if (!string.IsNullOrWhiteSpace(l))
                    {
                        var language = CodesManager.GetLanguage(l);
                        output.InLanguageCodeList.Add(new TextValueProfile()
                        {
                            CodeId    = language.CodeId,
                            TextTitle = language.Name,
                            TextValue = language.Value
                        });
                    }
                }

                if (input.InLanguage.Count > 0)
                {
                    //could use to alter helper.DefaultLanguage
                }
                output.Name           = helper.HandleLanguageMap(input.Name, output, "Name");
                output.Description    = helper.HandleLanguageMap(input.Description, output, "Description");
                output.SubjectWebpage = input.SubjectWebpage;
                output.CTID           = input.Ctid;
                //warning this gets set to blank if doing a manual import by ctid
                output.CredentialRegistryId = envelopeIdentifier;
                output.CredentialStatusType = helper.MapCAOToEnumermation(input.CredentialStatusType);
                output.DateEffective        = input.DateEffective;

                output.AlternateNames       = helper.MapToTextValueProfile(input.AlternateName, output, "AlternateName");
                output.ImageUrl             = input.Image;
                output.CredentialTypeSchema = input.CredentialType;


                output.AvailabilityListing = helper.MapListToString(input.AvailabilityListing);
                output.AvailableOnlineAt   = helper.MapListToString(input.AvailableOnlineAt);

                output.CredentialId = input.CredentialId;
                //TODO - develope entity for IdentitifierValue
                output.VersionIdentifier     = helper.MapIdentifierValueListToString(input.VersionIdentifier);
                output.VersionIdentifierList = helper.MapIdentifierValueList(input.VersionIdentifier);

                output.CodedNotation = input.CodedNotation;
                output.ISICV4        = input.IsicV4;

                output.ProcessStandards            = input.ProcessStandards;
                output.ProcessStandardsDescription = helper.HandleLanguageMap(input.ProcessStandardsDescription, output, "ProcessStandardsDescription");
                output.LatestVersion   = input.LatestVersion;
                output.PreviousVersion = input.PreviousVersion;
                output.NextVersion     = input.NextVersion;
                output.SupersededBy    = input.SupersededBy;
                output.Supersedes      = input.Supersedes;

                output.Subject = helper.MapCAOListToTextValueProfile(input.Subject, CodesManager.PROPERTY_CATEGORY_SUBJECT);

                //occupations
                //output.Occupation = helper.MapCAOListToEnumermation( input.OccupationType );
                //actually used by import
                output.Occupations = helper.MapCAOListToCAOProfileList(input.OccupationType);
                //just append alternative items. Ensure empty lists are ignored
                output.Occupations.AddRange(helper.AppendLanguageMapListToCAOProfileList(input.AlternativeOccupationType));

                //skip if no occupations
                if (output.Occupations.Count() == 0 &&
                    UtilityManager.GetAppKeyValue("skipCredImportIfNoOccupations", false))
                {
                    //LoggingHelper.DoTrace( 2, string.Format( "		***Skipping Credential# {0}, {1} as it has no occupations and this is a special run.", output.Id, output.Name ) );
                    //return true;
                }
                //Industries
                output.Industries = helper.MapCAOListToCAOProfileList(input.IndustryType);
                output.Industries.AddRange(helper.AppendLanguageMapListToCAOProfileList(input.AlternativeIndustryType));
                //naics
                output.Naics = input.Naics;

                output.InstructionalProgramTypes = helper.MapCAOListToCAOProfileList(input.InstructionalProgramType);
                output.InstructionalProgramTypes.AddRange(helper.AppendLanguageMapListToCAOProfileList(input.AlternativeInstructionalProgramType));
                //
                //will want a custom method to lookup the rating
                NavyServices nsrvs = new NavyServices();
                output.NavyRating = NavyServices.MapRatingsListToEnumermation(input.HasRating);
                output.NavyRatingType.AddRange(nsrvs.MapCAOListToCAOProfileList(input.HasRating, ref messages));
                //

                output.Keyword = helper.MapToTextValueProfile(input.Keyword, output, "Keyword");

                output.Jurisdiction = helper.MapToJurisdiction(input.Jurisdiction, ref status);
                //CopyrightHolder - expecting single; will need to expand
                output.CopyrightHolder = helper.MapOrganizationReferencesGuid("Credential.CopyrightHolder", input.CopyrightHolder, ref status);
                //CAO
                output.AudienceLevelType = helper.MapCAOListToEnumermation(input.AudienceLevelType);
                //
                output.AudienceType        = helper.MapCAOListToEnumermation(input.AudienceType);
                output.DegreeConcentration = helper.MapCAOListToTextValueProfile(input.DegreeConcentration, CodesManager.PROPERTY_CATEGORY_DEGREE_CONCENTRATION);
                output.DegreeMajor         = helper.MapCAOListToTextValueProfile(input.DegreeMajor, CodesManager.PROPERTY_CATEGORY_DEGREE_MAJOR);
                output.DegreeMinor         = helper.MapCAOListToTextValueProfile(input.DegreeMinor, CodesManager.PROPERTY_CATEGORY_DEGREE_MINOR);

                output.AssessmentDeliveryType = helper.MapCAOListToEnumermation(input.AssessmentDeliveryType);
                output.LearningDeliveryType   = helper.MapCAOListToEnumermation(input.LearningDeliveryType);

                //EstimatedCost
                //will need to format, all populate Entity.RelatedCosts (for bubble up) - actually this would be for asmts, and lopps
                output.EstimatedCost = helper.FormatCosts(input.EstimatedCost, ref status);

                //EstimatedDuration
                output.EstimatedDuration = helper.FormatDuration(input.EstimatedDuration, ref status);
                output.RenewalFrequency  = helper.FormatDurationItem(input.RenewalFrequency);

                //conditions
                output.Requires    = helper.FormatConditionProfile(input.Requires, ref status);
                output.Recommends  = helper.FormatConditionProfile(input.Recommends, ref status);
                output.Renewal     = helper.FormatConditionProfile(input.Renewal, ref status);
                output.Corequisite = helper.FormatConditionProfile(input.Corequisite, ref status);
                output.Revocation  = helper.FormatRevocationProfile(input.Revocation, ref status);

                //connections
                output.AdvancedStandingFrom = helper.FormatConditionProfile(input.AdvancedStandingFrom, ref status);
                output.AdvancedStandingFor  = helper.FormatConditionProfile(input.IsAdvancedStandingFor, ref status);

                output.PreparationFrom  = helper.FormatConditionProfile(input.PreparationFrom, ref status);
                output.IsPreparationFor = helper.FormatConditionProfile(input.IsPreparationFor, ref status);

                output.IsRequiredFor    = helper.FormatConditionProfile(input.IsRequiredFor, ref status);
                output.IsRecommendedFor = helper.FormatConditionProfile(input.IsRecommendedFor, ref status);

                //common conditions
                output.ConditionManifestIds = helper.MapEntityReferences(input.CommonConditions, CodesManager.ENTITY_TYPE_CONDITION_MANIFEST, CodesManager.ENTITY_TYPE_CREDENTIAL, ref status);
                //common costs
                output.CostManifestIds = helper.MapEntityReferences(input.CommonCosts, CodesManager.ENTITY_TYPE_COST_MANIFEST, CodesManager.ENTITY_TYPE_CREDENTIAL, ref status);

                //HasPart/IsPart
                //WARNING - these methods assume all parts are the same type - the provided thisEntityTypeId. AT THIS TIME, THE PARTS SHOULD ALL BE CREDENTIALS
                output.HasPartIds  = helper.MapEntityReferences(input.HasPart, thisEntityTypeId, ref status);
                output.IsPartOfIds = helper.MapEntityReferences(input.IsPartOf, thisEntityTypeId, ref status);

                //Process profiles
                output.AdministrationProcess = helper.FormatProcessProfile(input.AdministrationProcess, ref status);
                output.DevelopmentProcess    = helper.FormatProcessProfile(input.DevelopmentProcess, ref status);
                output.MaintenanceProcess    = helper.FormatProcessProfile(input.MaintenanceProcess, ref status);

                output.AppealProcess     = helper.FormatProcessProfile(input.AppealProcess, ref status);
                output.ComplaintProcess  = helper.FormatProcessProfile(input.ComplaintProcess, ref status);
                output.ReviewProcess     = helper.FormatProcessProfile(input.ReviewProcess, ref status);
                output.RevocationProcess = helper.FormatProcessProfile(input.RevocationProcess, ref status);

                //FinancialAssistance
                output.FinancialAssistance = helper.FormatFinancialAssistance(input.FinancialAssistance, ref status);


                output.Addresses = helper.FormatAvailableAtAddresses(input.AvailableAt, ref status);

                //BYs
                output.AccreditedBy = helper.MapOrganizationReferenceGuids("Credential.AccreditedBy", input.AccreditedBy, ref status);
                output.ApprovedBy   = helper.MapOrganizationReferenceGuids("Credential.ApprovedBy", input.ApprovedBy, ref status);
                output.OfferedBy    = helper.MapOrganizationReferenceGuids("Credential.OfferedBy", input.OfferedBy, ref status);
                //note need to set output.OwningAgentUid to the first entry
                output.OwnedBy = helper.MapOrganizationReferenceGuids("Credential.OwnedBy", input.OwnedBy, ref status);
                if (output.OwnedBy != null && output.OwnedBy.Count > 0)
                {
                    output.OwningAgentUid = output.OwnedBy[0];
                }
                else
                {
                    //add warning?
                    if (output.OfferedBy == null && output.OfferedBy.Count == 0)
                    {
                        status.AddWarning("document doesn't have an owning or offering organization.");
                    }
                }

                output.RecognizedBy = helper.MapOrganizationReferenceGuids("Credential.RecognizedBy", input.RecognizedBy, ref status);
                output.RegulatedBy  = helper.MapOrganizationReferenceGuids("Credential.RegulatedBy", input.RegulatedBy, ref status);
                output.RevokedBy    = helper.MapOrganizationReferenceGuids("Credential.RevokedBy", input.RevokedBy, ref status);
                output.RenewedBy    = helper.MapOrganizationReferenceGuids("Credential.RenewedBy", input.RenewedBy, ref status);

                //INs
                output.AccreditedIn = helper.MapToJurisdiction(input.AccreditedIn, ref status);
                output.ApprovedIn   = helper.MapToJurisdiction(input.ApprovedIn, ref status);
                output.ApprovedIn   = helper.MapToJurisdiction(input.ApprovedIn, ref status);
                output.RecognizedIn = helper.MapToJurisdiction(input.RecognizedIn, ref status);
                output.RegulatedIn  = helper.MapToJurisdiction(input.RegulatedIn, ref status);
                output.RevokedIn    = helper.MapToJurisdiction(input.RevokedIn, ref status);
                output.RenewedIn    = helper.MapToJurisdiction(input.RenewedIn, ref status);

                //=== if any messages were encountered treat as warnings for now
                if (messages.Count > 0)
                {
                    status.SetMessages(messages, true);
                }
                //just in case check if entity added since start
                if (output.Id == 0)
                {
                    ThisEntity entity = EntityServices.GetByCtid(ctid);
                    if (entity != null && entity.Id > 0)
                    {
                        output.Id    = entity.Id;
                        output.RowId = entity.RowId;
                    }
                }
                //save the data
                importSuccessfull    = mgr.Import(output, ref status);
                status.DocumentId    = output.Id;
                status.DetailPageUrl = string.Format("~/credential/{0}", output.Id);
                status.DocumentRowId = output.RowId;

                //if record was added to db, add to/or set EntityResolution as resolved
                int ierId = new ImportManager().Import_EntityResolutionAdd(referencedAtId,
                                                                           ctid,
                                                                           CodesManager.ENTITY_TYPE_CREDENTIAL,
                                                                           output.RowId,
                                                                           output.Id,
                                                                           (output.Id > 0),
                                                                           ref messages,
                                                                           output.Id > 0);
                //just in case
                if (status.HasErrors)
                {
                    importSuccessfull = false;
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format("Exception encountered in envelopeId: {0}", envelopeIdentifier), false, "workIT Import exception");
            }

            return(importSuccessfull);
        }