private void GetTemplateData(int templateId, bool loadControl = true) { var template = new CommunicationTemplateService(new RockContext()).Get(templateId); if (template != null) { var channelData = template.ChannelData; if (!channelData.ContainsKey("Subject")) { channelData.Add("Subject", template.Subject); } foreach (var dataItem in channelData) { if (!string.IsNullOrWhiteSpace(dataItem.Value)) { if (ChannelData.ContainsKey(dataItem.Key)) { ChannelData[dataItem.Key] = dataItem.Value; } else { ChannelData.Add(dataItem.Key, dataItem.Value); } } } if (loadControl) { LoadChannelControl(true); } } }
/// <summary> /// Sets a channel data value. If the key exists, the value will be replaced with the new value, otherwise a new key value pair will be added to dictionary. /// </summary> /// <param name="key">A <see cref="System.String"/> representing the key.</param> /// <param name="value">A <see cref="System.String"/> representing the value.</param> public void SetChannelDataValue(string key, string value) { if (ChannelData.ContainsKey(key)) { ChannelData[key] = value; } else { ChannelData.Add(key, value); } }
/// <summary> /// Returns a channel data value. /// </summary> /// <param name="key">A <see cref="System.String"/> containing the key associated with the value to retrieve. </param> /// <returns>A <see cref="System.String"/> representing the value that is linked with the specified key.</returns> public string GetChannelDataValue(string key) { if (ChannelData.ContainsKey(key)) { return(ChannelData[key]); } else { return(string.Empty); } }
/// <summary> /// Gets the channel data. /// </summary> private void GetChannelData() { if (phContent.Controls.Count == 1 && phContent.Controls[0] is ChannelControl) { var channelData = ((ChannelControl)phContent.Controls[0]).ChannelData; foreach (var dataItem in channelData) { if (ChannelData.ContainsKey(dataItem.Key)) { ChannelData[dataItem.Key] = dataItem.Value; } else { ChannelData.Add(dataItem.Key, dataItem.Value); } } } }