public ContactModel(IReadOnlyDictionary <string, string> options, IMLNetService mlNetService, ITableStoreFactory tableStoreFactory) : base(tableStoreFactory) { _mlNetService = mlNetService; _tableStoreFactory = tableStoreFactory; Projection = Sitecore.Processing.Engine.Projection.Projection.Of <Contact>().CreateTabular( "ContactModel", cfg => cfg .Key("ContactId", c => c.Id) .Attribute("Enabled", c => c.GetFacet <RfmContactFacet>() == null ? 0 : 1) .Attribute("R", c => c.GetFacet <RfmContactFacet>() == null ? 0 : c.GetFacet <RfmContactFacet>().R) .Attribute("F", c => c.GetFacet <RfmContactFacet>() == null ? 0 : c.GetFacet <RfmContactFacet>().F) .Attribute("M", c => c.GetFacet <RfmContactFacet>() == null ? 0 : c.GetFacet <RfmContactFacet>().M) .Attribute("Recency", c => c.GetFacet <RfmContactFacet>() == null ? 0 : c.GetFacet <RfmContactFacet>().Recency) .Attribute("Frequency", c => c.GetFacet <RfmContactFacet>() == null ? 0 : c.GetFacet <RfmContactFacet>().Frequency) .Attribute("Monetary", c => c.GetFacet <RfmContactFacet>() == null ? 0 : c.GetFacet <RfmContactFacet>().Monetary) .Attribute("Email", c => c.Emails()?.PreferredEmail?.SmtpAddress, nullable: true)); }
public PurchaseInteractionModel(IReadOnlyDictionary <string, string> options, IMLNetService mlNetService, ITableStoreFactory tableStoreFactory) : base(tableStoreFactory) { _tableStoreFactory = tableStoreFactory; _mlNetService = mlNetService; Projection = Sitecore.Processing.Engine.Projection.Projection.Of <Interaction>() .CreateTabular("PurchaseOutcome", interaction => interaction.Events.OfType <PurchaseOutcome>().Select(p => new { Purchase = p, interaction.IpInfo()?.Country }), cfg => cfg.Key("Id", x => x.Purchase.Id) .Attribute(nameof(PurchaseInvoice.Quantity), x => x.Purchase.Quantity) .Attribute(nameof(PurchaseInvoice.TimeStamp), x => x.Purchase.Timestamp) .Attribute(nameof(PurchaseInvoice.Price), x => x.Purchase.UnitPrice) .Attribute(nameof(PurchaseInvoice.StockCode), x => x.Purchase.ProductId) .Attribute(nameof(PurchaseInvoice.Country), x => x.Country, true) ); }