private void DeployTermLabel(object modelHost, TermModelHost termModelHost, TaxonomyTermLabelDefinition labelModel)
        {
            var termStore = termModelHost.HostTermStore;
            var context = termStore.Context;

            var term = termModelHost.HostTerm;
            var currentLabel = FindLabelInTerm(term, labelModel);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = currentLabel,
                ObjectType = typeof(Label),
                ObjectDefinition = labelModel,
                ModelHost = modelHost
            });

            if (currentLabel == null)
            {
                TraceService.Verbose((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new Label");

                currentLabel = term.CreateLabel(labelModel.Name, labelModel.LCID, labelModel.IsDefault);

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioned,
                    Object = currentLabel,
                    ObjectType = typeof(Label),
                    ObjectDefinition = labelModel,
                    ModelHost = modelHost
                });
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing Term");

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioned,
                    Object = currentLabel,
                    ObjectType = typeof(Label),
                    ObjectDefinition = labelModel,
                    ModelHost = modelHost
                });
            }

            termStore.CommitAll();
            context.ExecuteQueryWithTrace();
        }
        protected Label FindLabelInTerm(Term termSet, TaxonomyTermLabelDefinition labelModel)
        {
            var context = termSet.Context;
            var labels = termSet.Labels;

            context.Load(labels);
            context.ExecuteQueryWithTrace();

            return termSet.Labels.ToList().FirstOrDefault(l => l.Value.ToUpper() == labelModel.Name.ToUpper());
        }
 public static ModelNode AddTaxonomyTermLabel(this ModelNode model, TaxonomyTermLabelDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
        protected Label FindLabelInTerm(Term termSet, TaxonomyTermLabelDefinition labelModel)
        {
            var result = termSet.Labels.FirstOrDefault(l => l.Value.ToUpper() == labelModel.Name.ToUpper());

            return result;
        }
 public static ModelNode AddTaxonomyTermLabel(this ModelNode model, TaxonomyTermLabelDefinition definition)
 {
     return AddTaxonomyTermLabel(model, definition, null);
 }