private AffiliationCode ConvertToAffiliation(DataRow row) { var times_redeemed = 0; var Code = row.Field <String>("AffiliateCode"); var coupon = StripeHelper.GetCoupon(Code); var sales = row.Field <Decimal>("Sales"); if (coupon != null) { times_redeemed = coupon.TimesRedeemed; } var couponamount = row.Field <Decimal>("Amount"); var actualPrice = row.Field <Decimal>("PreOffSale"); var offInPercent = row.Field <int>("Percent_off"); var customers = row.Field <int>("Subscribers"); var commision = Math.Round(row.Field <Decimal>("Commision"), 2); var assignId = row.Field <int>("AssignId"); return(new AffiliationCode() { ID = row.Field <int>("AffiliateID"), Code = Code, Percent = offInPercent, Duration = row.Field <int>("Duration"), Sales = sales, Subscribers = customers, Amount = couponamount, Max = row.Field <int>("Maxredeem"), Redeemby = row.Field <DateTime?>("Redeemby"), PreDiscountSale = actualPrice, AffiliateCommission = (commision <= 0.00M)?0.00M: commision, CreatedBy = row.Field <string>("CreatedBy"), IsAssigned = assignId <= 0 ? false : true, RedeemedCount = times_redeemed }); }