public static CreateEntityResponse Unmarshall(UnmarshallerContext context)
        {
            CreateEntityResponse createEntityResponse = new CreateEntityResponse();

            createEntityResponse.HttpResponse = context.HttpResponse;
            createEntityResponse.RequestId    = context.StringValue("CreateEntity.RequestId");
            createEntityResponse.EntityId     = context.StringValue("CreateEntity.EntityId");

            return(createEntityResponse);
        }
Example #2
0
        public bool CreateEntity(IOrganizationService service, XRMSpeedyEntity entity, int languageCode)
        {
            try
            {
                CreateEntityRequest createRequest = new CreateEntityRequest
                {
                    Entity = new EntityMetadata
                    {
                        SchemaName            = entity.EntityMetadata.SchemaName,
                        DisplayName           = entity.EntityMetadata.DisplayName,
                        DisplayCollectionName = entity.EntityMetadata.DisplayCollectionName,
                        Description           = entity.EntityMetadata.Description,
                        OwnershipType         = entity.EntityMetadata.OwnershipType,
                        IsActivity            = false
                    },

                    // Define the primary attribute for the entity
                    PrimaryAttribute = new StringAttributeMetadata
                    {
                        SchemaName = entity.ShortPrimaryAttributeName
                            ? entity.EntityMetadata.SchemaName.Split('_')[0] + "_" + "name"
                            : entity.EntityMetadata.SchemaName + "name",
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.ApplicationRequired),
                        MaxLength     = entity.PrimaryAttributeSize,
                        Format        = StringFormat.Text,
                        DisplayName   = new Label("Name", languageCode),
                        Description   = new Label("The primary attribute for the entity.", languageCode)
                    }
                };

                CreateEntityResponse response = (CreateEntityResponse)service.Execute(createRequest);

                return(CreateAttributes(service, entity, languageCode));
            }
            catch (FaultException <OrganizationServiceFault> )
            {
                throw;
            }
        }
Example #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateEntityResponse response = new CreateEntityResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("arn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Arn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("creationDateTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreationDateTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("entityId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EntityId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("state", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.State = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }