Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to get Facets and Elements from xDB
public KeyInteractionsModel Get(Contact contact)
{
var keyInteractionsModel = new KeyInteractionsModel();
keyInteractionsModel.SwatchesDownloaded =
GetSwatchesDownloaded(contact)
.Select(s => new KeyValuePair<string, string>(s.DecorId, s.RangeId));
keyInteractionsModel.VideosPlayed =
GetVideosPlayed(contact)
.Select(v => new KeyValuePair<string, string>(v.VideoId, v.VideoUrl));
keyInteractionsModel.SampleOrders = GetSampleOrders(contact)
.Select(s => new KeyValuePair<string, string>(s.DecorId, s.RangeId));
return keyInteractionsModel;
}
public IElementCollection<ISwatchDownloadedElement> GetSwatchesDownloaded(Contact contact)
{
IKeyInteractionsFacet facet = contact.GetFacet<IKeyInteractionsFacet>(KeyInteractionsFacet.FacetName);
return facet.SwatchesDownloaded;
}
public IElementCollection<IVideoPlayedElement> GetVideosPlayed(Contact contact)
{
IKeyInteractionsFacet facet = contact.GetFacet<IKeyInteractionsFacet>(KeyInteractionsFacet.FacetName);
return facet.VideosPlayed;
}
public IElementCollection<ISampleOrderElement> GetSampleOrders(Contact contact)
{
IKeyInteractionsFacet facet = contact.GetFacet<IKeyInteractionsFacet>(KeyInteractionsFacet.FacetName);
return facet.SampleOrders;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment