Esempio n. 1
0
        }         //

        public List <MC.CredentialAlignmentObjectProfile> MapCAOListToCAOProfileList(List <string> input, ref List <string> messages)
        {
            List <MC.CredentialAlignmentObjectProfile> output = new List <workIT.Models.Common.CredentialAlignmentObjectProfile>();

            MC.CredentialAlignmentObjectProfile entity = new MC.CredentialAlignmentObjectProfile();

            if (input == null || input.Count == 0)
            {
                return(output);
            }
            string ctdlType = "";
            string status   = "";

            foreach (var item in input)
            {
                string resource = RegistryServices.GetResourceByUrl(item, ref ctdlType, ref status);
                if (string.IsNullOrWhiteSpace(resource))
                {
                    messages.Add(string.Format("NavyServices.MapCAOListToCAOProfileList. Unable to resolve Rating URL: {0}", item));
                    continue;
                }
                var rating = Newtonsoft.Json.JsonConvert.DeserializeObject <RatingEntity>(resource);

                if (rating != null && (rating.Name != null))
                {
                    entity = new MC.CredentialAlignmentObjectProfile()
                    {
                        TargetNode    = rating.CtdlId,
                        CodedNotation = rating.CodedNotation ?? ""
                    };

                    entity.TargetNodeName            = HandleLanguageMap(rating.Name, currentBaseObject, "TargetNodeName");
                    entity.TargetNodeName_Map        = lastLanguageMapString;
                    entity.TargetNodeDescription     = HandleLanguageMap(rating.Description, currentBaseObject, "TargetNodeDescription", false);
                    entity.TargetNodeDescription_Map = lastLanguageMapString;

                    //if ( !string.IsNullOrWhiteSpace( item.Framework ) )
                    //{
                    //	if ( item.Framework.ToLower().IndexOf( "credentialengineregistry.org/resources/ce-" ) == -1
                    //		&& item.Framework.ToLower().IndexOf( "credentialengineregistry.org/graph/ce-" ) == -1 )
                    //	{
                    //		entity.SourceUrl = item.Framework;
                    //	}
                    //	else
                    //	{
                    //		entity.FrameworkUri = item.Framework;
                    //	}
                    //}
                    output.Add(entity);
                }
            }
            return(output);
        }
        //used by detail page to combine all CAOs frameworks
        public static List <CredentialAlignmentObjectProfile> FlattenAlignmentObjects(List <CredentialAlignmentObjectFrameworkProfile> data)
        {
            var result = new List <CredentialAlignmentObjectProfile>();
            CredentialAlignmentObjectProfile entity = new CredentialAlignmentObjectProfile();

            foreach (var framework in data)
            {
                foreach (var item in framework.Items)
                {
                    entity = new CredentialAlignmentObjectProfile()
                    {
                        //Framework = string.IsNullOrWhiteSpace( framework.FrameworkName ) ? framework.FrameworkName : framework.FrameworkUrl,
                        FrameworkName = framework.FrameworkName,
                        //FrameworkUrl = framework.FrameworkUrl,
                        TargetNodeName        = item.TargetNodeName,
                        TargetNodeDescription = item.TargetNodeDescription,
                        //TargetUrl = string.IsNullOrWhiteSpace( item.TargetUrl ) ? framework.EducationalFrameworkUrl : item.TargetUrl,
                        TargetNode    = item.TargetNode,
                        ProfileName   = item.ProfileName,
                        Description   = item.Description,
                        CodedNotation = item.CodedNotation,
                        Weight        = item.Weight
                    };
                    if (!string.IsNullOrWhiteSpace(framework.FrameworkUri))
                    {
                        entity.FrameworkUri = framework.FrameworkUri;
                    }
                    else
                    {
                        entity.SourceUrl = framework.SourceUrl;
                    }

                    result.Add(entity);
                }
            }

            return(result);
        }