public WebAPIAttributeItemModel(AttributeMetadata metadata, EntityItemModel selectedEntityInfo, bool isCustomerAttribute = false, CustomerType customerType = CustomerType.Account) { Metadata = metadata; if (metadata.DisplayName.UserLocalizedLabel != null && !string.IsNullOrEmpty(metadata.DisplayName.UserLocalizedLabel.Label)) { DisplayName = metadata.DisplayName.UserLocalizedLabel.Label; } else { DisplayName = metadata.DisplayName.ToString(); } WebAPIName = LogicalName = metadata.LogicalName; DataType = metadata.AttributeType.Value; IsValidForCreate = metadata.IsValidForCreate.Value; IsValidForUpdate = metadata.IsValidForUpdate.Value; if (metadata.AttributeType == AttributeTypeCode.Customer) { var relationships = selectedEntityInfo.MToOneRelationships.Where(x => x.ReferencingAttribute == metadata.LogicalName).ToList(); if (relationships.Count > 1) { WebAPIName = relationships[(int)customerType].ReferencingEntityNavigationPropertyName; RelatedEntityCollectionName = GetRelatedEntityCollecitonName(relationships[(int)customerType].ReferencedEntity); } } else if (metadata.AttributeType == AttributeTypeCode.Lookup) { if (metadata.LogicalName == "a51_testcase") { } var relationships = selectedEntityInfo.MToOneRelationships.Where(x => x.ReferencingAttribute == metadata.LogicalName).ToList(); if (relationships.Count > 0) { WebAPIName = relationships[0].ReferencingEntityNavigationPropertyName; RelatedEntityCollectionName = GetRelatedEntityCollecitonName(relationships[0].ReferencedEntity); } } }
public void UpdateSelectedEntity(EntityItemModel entityItemModel) { SelectedEntityInfo = entityItemModel; }
public void AddEntity(EntityItemModel entity) { AllEntitiesList?.Add(entity); }