Beispiel #1
0
        private void MapRelationshipAttributesToEntity(Entity source, ICrmService crm, OrganizationServiceContext context)
        {
            foreach (var property in GetProperties(this))
            {
                var attribute = EntityRelationshipAttribute(property);
                var value     = property.GetValue(this);

                if (attribute == null || value == null)
                {
                    continue;
                }

                foreach (var relatedModel in EnumerableRelationshipModels(value))
                {
                    var shouldMap = ShouldMapRelationship(property.Name, relatedModel, crm);
                    if (!shouldMap)
                    {
                        continue;
                    }

                    var target = relatedModel.ToEntity(crm, context);
                    crm.AddLink(source, new Relationship(attribute.Name), target, context);
                }
            }
        }
Beispiel #2
0
        public void AddLink_ProxiesToService()
        {
            var source       = new Entity("parent");
            var target       = new Entity("child");
            var relationship = new Relationship("child");

            _crm.AddLink(source, relationship, target, _context);

            _mockService.Verify(mock => mock.AddLink(source, relationship, target, _context));
        }