-
-
Save islaytitans/a32399dd4eec1cad2318 to your computer and use it in GitHub Desktop.
Repository pattern used to write data to Sitecore's Experience Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KeyInteractionsRepository : IKeyInteractionsRepository | |
{ | |
public void Write(Contact contact, KeyInteractionsModel model) | |
{ | |
IKeyInteractionsFacet facet = contact.GetFacet<IKeyInteractionsFacet>(KeyInteractionsFacet.FacetName); | |
if (model.SwatchesDownloaded != null && model.SwatchesDownloaded.Any()) | |
{ | |
foreach (KeyValuePair<string, string> keyValuePair in model.SwatchesDownloaded) | |
{ | |
var swatch = facet.SwatchesDownloaded.Create(); | |
swatch.DecorId = keyValuePair.Value; | |
swatch.RangeId = keyValuePair.Key; | |
} | |
} | |
if (model.VideosPlayed != null && model.VideosPlayed.Any()) | |
{ | |
foreach (KeyValuePair<string, string> videoPlayed in model.VideosPlayed) | |
{ | |
var video = facet.VideosPlayed.Create(); | |
video.VideoId = videoPlayed.Key; | |
video.VideoUrl = videoPlayed.Value; | |
} | |
} | |
if (model.SampleOrders != null && model.SampleOrders.Any()) | |
{ | |
foreach (var sampleOrder in model.SampleOrders) | |
{ | |
var sampleOrdered = facet.SampleOrders.Create(); | |
sampleOrdered.DecorId = sampleOrder.Key; | |
sampleOrdered.RangeId = sampleOrder.Value; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment