/// <summary>
        /// Gets the component by entity identifier, and creates it if it doesn't exist
        /// </summary>
        /// <param name="channelGuid">The channel unique identifier.</param>
        /// <param name="entityId">The entity identifier.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public InteractionComponent GetComponentByEntityId(Guid channelGuid, int entityId, string name)
        {
            var component = this.Queryable()
                            .FirstOrDefault(c =>
                                            c.Channel.Guid == channelGuid &&
                                            c.EntityId == entityId);

            if (component != null)
            {
                component.Name = name;
            }
            else
            {
                var channel = new InteractionChannelService((RockContext)this.Context).Get(channelGuid);
                if (channel != null)
                {
                    component           = new InteractionComponent();
                    component.EntityId  = entityId;
                    component.ChannelId = channel.Id;
                    component.Name      = name;
                    this.Add(component);
                }
            }

            component.Name = name;

            return(component);
        }
 /// <summary>
 /// Clones this InteractionComponent object to a new InteractionComponent object
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param>
 /// <returns></returns>
 public static InteractionComponent Clone(this InteractionComponent source, bool deepCopy)
 {
     if (deepCopy)
     {
         return(source.Clone() as InteractionComponent);
     }
     else
     {
         var target = new InteractionComponent();
         target.CopyPropertiesFrom(source);
         return(target);
     }
 }
Example #3
0
 /// <summary>
 /// Copies the properties from another InteractionComponent object to this InteractionComponent object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this InteractionComponent target, InteractionComponent source)
 {
     target.Id                      = source.Id;
     target.ChannelId               = source.ChannelId;
     target.ComponentData           = source.ComponentData;
     target.ComponentSummary        = source.ComponentSummary;
     target.EntityId                = source.EntityId;
     target.ForeignGuid             = source.ForeignGuid;
     target.ForeignKey              = source.ForeignKey;
     target.Name                    = source.Name;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid                    = source.Guid;
     target.ForeignId               = source.ForeignId;
 }
Example #4
0
        /// <summary>
        /// Gets the component by predicate.
        /// </summary>
        /// <param name="channelId">The channel identifier.</param>
        /// <param name="entityId">The entity identifier.</param>
        /// <param name="name">The name.</param>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        private InteractionComponent GetComponentByPredicate(int channelId, int?entityId, string name, System.Linq.Expressions.Expression <Func <InteractionComponent, bool> > predicate)
        {
            var component = this.Queryable()
                            .FirstOrDefault(predicate);

            if (component != null)
            {
                component.Name = name;
            }
            else
            {
                component                      = new InteractionComponent();
                component.EntityId             = entityId;
                component.InteractionChannelId = channelId;
                component.Name                 = name;
                this.Add(component);
            }

            return(component);
        }
 /// <summary>
 /// Copies the properties from another InteractionComponent object to this InteractionComponent object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this InteractionComponent target, InteractionComponent source)
 {
     target.Id                    = source.Id;
     target.ChannelCustom1        = source.ChannelCustom1;
     target.ChannelCustom2        = source.ChannelCustom2;
     target.ChannelCustomIndexed1 = source.ChannelCustomIndexed1;
     #pragma warning disable 612, 618
     target.ChannelId = source.ChannelId;
     #pragma warning restore 612, 618
     target.ComponentData        = source.ComponentData;
     target.ComponentSummary     = source.ComponentSummary;
     target.EntityId             = source.EntityId;
     target.ForeignGuid          = source.ForeignGuid;
     target.ForeignKey           = source.ForeignKey;
     target.InteractionChannelId = source.InteractionChannelId;
     target.Name                    = source.Name;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid                    = source.Guid;
     target.ForeignId               = source.ForeignId;
 }
        /// <summary>
        /// Gets the component by component name, and creates it if it doesn't exist
        /// </summary>
        /// <param name="channelId">The channel identifier.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public InteractionComponent GetComponentByComponentName(int channelId, string name)
        {
            var component = this.Queryable()
                            .FirstOrDefault(c =>
                                            c.ChannelId == channelId &&
                                            c.Name == name);

            if (component != null)
            {
                component.Name = name;
            }
            else
            {
                component           = new InteractionComponent();
                component.EntityId  = null;
                component.ChannelId = channelId;
                component.Name      = name;
                this.Add(component);
            }

            component.Name = name;

            return(component);
        }