Exemplo n.º 1
0
        public override BaseResource[] SynchronizeIds(BaseResource[] source, Uri subjectUri, BaseResource[] target)
        {
            MnisGovernmentPosition governmentPosition = source.OfType <MnisGovernmentPosition>().SingleOrDefault();

            governmentPosition.Id = subjectUri;

            return(new BaseResource[] { governmentPosition });
        }
Exemplo n.º 2
0
        public override BaseResource[] TransformSource(XDocument doc)
        {
            MnisGovernmentPosition governmentPosition = new MnisGovernmentPosition();
            XElement element = doc.Descendants(d + "GovernmentPost_Id").SingleOrDefault();

            if ((element == null) || (element.Parent == null))
            {
                return(null);
            }

            XElement elementPosition = element.Parent;

            governmentPosition.GovernmentPositionMnisId = elementPosition.Element(d + "GovernmentPost_Id").GetText();
            governmentPosition.PositionName             = elementPosition.Element(d + "Name").GetText();
            List <Group> groups = new List <Group>();

            foreach (XElement elementLoop in doc.Descendants(d + "Department_Id"))
            {
                if ((elementLoop != null) && (elementLoop.Parent != null))
                {
                    XElement departmentElement = elementLoop.Parent;
                    string   departmentId      = departmentElement.Element(d + "Department_Id").GetText();
                    if (string.IsNullOrWhiteSpace(departmentId) == false)
                    {
                        Uri departmentUri = IdRetrieval.GetSubject("mnisDepartmentId", departmentId, false, logger);
                        if (departmentUri != null)
                        {
                            groups.Add(new Group()
                            {
                                Id = departmentUri
                            });
                        }
                    }
                }
            }
            governmentPosition.PositionHasGroup = groups;
            return(new BaseResource[] { governmentPosition });
        }