Ian Robinson
04/04/2024, 4:10 PMLewis Heaton
04/04/2024, 4:11 PMIan Robinson
04/04/2024, 4:22 PMc#
var parentPage = _contentService.GetById(model.CurrentPageID);
foreach (var property in parentPage!.Properties)
{
if (property.PropertyType.PropertyEditorAlias == "Umbraco.BlockList")
{
foreach (var val in property.Values)
{
string rawJson = val.PublishedValue.ToString();
BlockValue blockValue = JsonConvert.DeserializeObject<BlockValue>(rawJson);
// there should only be one itme with a matching UniqueId value
foreach (BlockItemData blockItemData in blockValue.ContentData.Where(x => x.Key == Guid.Parse(model.UniqueID)))
{
var emailBodyJson = blockItemData.RawPropertyValues.Single(x => x.Key == "registrationConfirmationEmail").Value.ToString();
if (!emailBodyJson.IsNullOrEmpty()) {
var emailBodyJObj = (JObject)JsonConvert.DeserializeObject(emailBodyJson);
string emailBodyString = emailBodyJObj["markup"].Value<string>();
}
}
}
}
}
Ian Robinson
04/04/2024, 4:24 PM