示例#1
0
        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);
        }
示例#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);
        }
示例#3
0
        public static bool Enabled(this IDataRow dataRow)
        {
            var email = dataRow.Schema.Fields.FirstOrDefault(x => x.Name == "Enabled");

            if (email != null)
            {
                return(dataRow.GetInt64(dataRow.Schema.GetFieldIndex("Enabled")) == 1);
            }
            return(false);
        }
        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);
        }