public void FormatCompetencyChildren(ApiCompetency competency, InputCompetency input, List <InputCompetency> allCompetencies, MappingHelperV3 helper) { foreach (var item in input.hasChild) { //get the competency var c = allCompetencies.Where(s => s.CtdlId == item).FirstOrDefault(); if (c != null && !string.IsNullOrWhiteSpace(c.CTID)) { var ac = new ApiCompetency() { CompetencyText = helper.HandleLanguageMap(c.competencyText, "CompetencyText"), CTID = c.CTID, CompetencyLabel = helper.HandleLanguageMap(c.competencyLabel, "competencyLabel"), HasChild = null, HasChildId = null }; if (c.hasChild != null && c.hasChild.Any()) { ac.HasChild = new List <ApiCompetency>(); FormatCompetencyChildren(ac, c, allCompetencies, helper); } competency.HasChild.Add(ac); } else { //log error LoggingHelper.DoTrace(1, string.Format("ImportCompetencyFramework.FormatCompetencyChildren() CompetencyCTID: {0}, child: {1} was not found in the list of competencies", competency.CTID, item)); } } }
// public void FormatCompetenciesHierarchy(ApiEntity entity, List <InputCompetency> input, MappingHelperV3 helper) { /* * start with hasTopChild * loop through and fill out the hierarchy with embedded comps * * */ var output = new List <ApiCompetency>(); var ac = new ApiCompetency(); foreach (var item in entity.HasTopChild) { //get the competency var c = input.Where(s => s.CtdlId == item).FirstOrDefault(); if (c != null && !string.IsNullOrWhiteSpace(c.CTID)) { ac = new ApiCompetency() { CompetencyText = helper.HandleLanguageMap(c.competencyText, "CompetencyText"), CTID = c.CTID, CompetencyLabel = helper.HandleLanguageMap(c.competencyLabel, "competencyLabel"), HasChild = null, HasChildId = null }; if (c.hasChild != null && c.hasChild.Any()) { ac.HasChild = new List <ApiCompetency>(); FormatCompetencyChildren(ac, c, input, helper); } output.Add(ac); } else { //log error LoggingHelper.DoTrace(1, string.Format("ImportCompetencyFramework. Framewwork: {0}, TopChild: {1} was not found in the list of competencies", entity.Name, item)); } } entity.Meta_HasPart = output; }