} //

        public bool Import(string payload, string envelopeIdentifier, SaveStatus status)
        {
            LoggingHelper.DoTrace(7, "ImportConceptSchemes - entered.");
            List <string>       messages          = new List <string>();
            MappingHelperV3     helper            = new MappingHelperV3(10);
            bool                importSuccessfull = true;
            var                 input             = new InputEntity();
            var                 concept           = new InputConcept();
            var                 mainEntity        = new Dictionary <string, object>();
            List <InputConcept> concepts          = new List <InputConcept>();

            Dictionary <string, object> dictionary = RegistryServices.JsonToDictionary(payload);
            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);
            var    bnodes    = new List <BNode>();
            int    cntr      = 0;

            foreach (var item in graphList)
            {
                cntr++;
                //note older frameworks will not be in the priority order
                var main = item.ToString();
                if (cntr == 1 || main.IndexOf("skos:ConceptScheme") > -1)
                {
                    //HACK

                    if (main.IndexOf("skos:ConceptScheme") > -1)
                    {
                        input = JsonConvert.DeserializeObject <InputEntity>(main);
                    }
                }
                else
                {
                    //should just have concepts, but should check for bnodes
                    var child = item.ToString();
                    if (child.IndexOf("_:") > -1)
                    {
                        bnodes.Add(JsonConvert.DeserializeObject <BNode>(child));
                    }
                    else if (child.IndexOf("skos:Concept") > -1)
                    {
                        concepts.Add(JsonConvert.DeserializeObject <InputConcept>(child));
                    }
                    else
                    {
                        //unexpected
                    }
                }
            }

            //try
            //{
            //input = JsonConvert.DeserializeObject<InputGraph>( item.DecodedResource.ToString() );
            string ctid = input.CTID;

            status.Ctid = ctid;
            string referencedAtId = input.CtdlId;

            LoggingHelper.DoTrace(5, "		ctid: "+ ctid);
            LoggingHelper.DoTrace(5, "		@Id: "+ input.CtdlId);
            LoggingHelper.DoTrace(5, "		name: "+ input.Name.ToString());

            string framework = input.Name.ToString();
            var    org       = new MC.Organization();
            string orgCTID   = "";
            string orgName   = "";


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

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

            output.Name                    = helper.HandleLanguageMap(input.Name, output, "Name");
            output.Description             = helper.HandleLanguageMap(input.Description, output, "description");
            output.CTID                    = input.CTID;
            output.PrimaryOrganizationCTID = orgCTID;
            //
            var publisher = input.Publisher;

            output.PublisherUid = helper.MapOrganizationReferenceGuid("ConceptScheme.Publisher", input.Publisher, ref status);
            output.Creator      = helper.MapOrganizationReferenceGuids("ConceptScheme.Creator", input.Creator, ref status);
            //20-06-11 - need to get creator, publisher, owner where possible
            //	include an org reference with name, swp, and??
            //should check creator first? Or will publisher be more likely to have an account Ctid?
            if (output.Creator != null && output.Creator.Count() > 0)
            {
                //get org or pending stub
                //look up org name
                org = OrganizationManager.Exists(output.Creator[0]);
                output.OwnedBy.Add(output.Creator[0]);
            }
            else
            {
                if (output.PublisherUid != Guid.Empty)
                {
                    //get org or pending stub
                    //look up org name
                    org = OrganizationManager.Exists(output.PublisherUid);
                    output.OwnedBy.Add(output.PublisherUid);
                }
            }
            //
            if (org != null && org.Id > 0)
            {
                orgName = org.Name;
                output.OrganizationId        = org.Id;
                helper.CurrentOwningAgentUid = org.RowId;
            }

            output.CredentialRegistryId = envelopeIdentifier;
            output.HasConcepts          = new List <MC.Concept>();
            //?store concepts in string?
            if (concepts != null && concepts.Count > 0)
            {
                output.TotalConcepts = concepts.Count();
                foreach (var item in concepts)
                {
                    var c = new MC.Concept()
                    {
                        PrefLabel  = helper.HandleLanguageMap(item.PrefLabel, output, "PrefLabel"),
                        Definition = helper.HandleLanguageMap(item.Definition, output, "Definition"),
                        Notes      = helper.HandleLanguageMapList(item.Note, output),
                        CTID       = item.CTID
                    };
                    if (c.Notes != null && c.Notes.Any())
                    {
                        c.Note = c.Notes[0];
                    }
                    output.HasConcepts.Add(c);
                }
            }
            //20-07-02 just storing the index ready concepts
            output.ConceptsStore = JsonConvert.SerializeObject(output.HasConcepts, MappingHelperV3.GetJsonSettings());

            //adding common import pattern

            new ConceptSchemeServices().Import(output, ref status);

            //

            return(importSuccessfull);
        }