public static ClientEvent ToGoalOutcome(this IDataRow dataRow)
        {
            var result = new ClientEvent();
            var email  = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == Constants.DemoGoal.CustomerIdKey);

            if (email != null)
            {
                result.Email = dataRow.GetString(dataRow.Schema.GetFieldIndex(Constants.DemoGoal.CustomerIdKey));
            }

            var date = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == Constants.DemoGoal.ProjectionTimestamp);

            if (date != null)
            {
                result.TimeStamp = dataRow.GetDateTime(dataRow.Schema.GetFieldIndex(Constants.DemoGoal.ProjectionTimestamp));
            }

            var price = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == Constants.DemoGoal.ProjectionEngagementValue);

            if (price != null)
            {
                result.Value = (decimal)dataRow.GetDouble(dataRow.Schema.GetFieldIndex(Constants.DemoGoal.ProjectionEngagementValue));
            }

            return(result);
        }
Example #2
0
        public static RfmContactFacet MapToRfmFacet(this IDataRow dataRow)
        {
            var result = new RfmContactFacet();

            var r = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "R");

            if (r != null)
            {
                result.R = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex("R"));
            }
            var f = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "F");

            if (f != null)
            {
                result.F = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex("F"));
            }
            var m = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "M");

            if (m != null)
            {
                result.M = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex("M"));
            }

            var recency = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "Recency");

            if (recency != null)
            {
                result.Recency = dataRow.GetDouble(dataRow.Schema.GetFieldIndex("Recency"));
            }
            var frequency = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "Frequency");

            if (frequency != null)
            {
                result.Frequency = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex("Frequency"));
            }
            var monetary = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "Monetary");

            if (monetary != null)
            {
                result.Monetary = dataRow.GetDouble(dataRow.Schema.GetFieldIndex("Monetary"));
            }
            return(result);
        }
        public static PurchaseInvoice ToPurchaseOutcome(this IDataRow dataRow)
        {
            var result     = new PurchaseInvoice();
            var customerId = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseOutcome.CustomerId));

            if (customerId != null)
            {
                result.ContactId = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex(nameof(PurchaseOutcome.CustomerId)));
            }
            var invoiceId = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseOutcome.InvoiceId));

            if (invoiceId != null)
            {
                result.Number = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex(nameof(PurchaseOutcome.InvoiceId)));
            }

            var quantity = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseOutcome.Quantity));

            if (quantity != null)
            {
                result.Quantity = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex(nameof(PurchaseOutcome.Quantity)));
            }

            var date = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseOutcome.Timestamp));

            if (date != null)
            {
                result.TimeStamp = dataRow.GetDateTime(dataRow.Schema.GetFieldIndex(nameof(PurchaseOutcome.Timestamp)));
            }

            var price = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseOutcome.UnitPrice));

            if (price != null)
            {
                result.Price = (decimal)dataRow.GetDouble(dataRow.Schema.GetFieldIndex(nameof(PurchaseOutcome.UnitPrice)));
            }

            var productId = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseOutcome.ProductId));

            if (productId != null)
            {
                result.StockCode = dataRow.GetString(dataRow.Schema.GetFieldIndex(nameof(PurchaseOutcome.ProductId)));
            }

            var country = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "Country");

            if (country != null)
            {
                result.Country = dataRow.GetString(dataRow.Schema.GetFieldIndex("Country"));
            }

            return(result);
        }
        public static PurchaseInvoice ToPurchaseOutcome(this IDataRow dataRow)
        {
            var result = new PurchaseInvoice
            {
                StockCode = dataRow.GetString(dataRow.Schema.GetFieldIndex(nameof(PurchaseInvoice.StockCode))),
                Quantity  = (int)dataRow.GetInt64(dataRow.Schema.GetFieldIndex(nameof(PurchaseInvoice.Quantity))),
                TimeStamp = dataRow.GetDateTime(dataRow.Schema.GetFieldIndex(nameof(PurchaseInvoice.TimeStamp))),
                Price     = (decimal)dataRow.GetDouble(dataRow.Schema.GetFieldIndex(nameof(PurchaseInvoice.Price)))
            };

            var country = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == nameof(PurchaseInvoice.Country));

            if (country != null)
            {
                result.Country = dataRow.GetString(dataRow.Schema.GetFieldIndex(nameof(PurchaseInvoice.Country)));
            }

            return(result);
        }