i am using nopcommerce 1.9 and in creating discount i have the following code
discount = new Discount()
{
DiscountTypeId = (int)discountType,
DiscountRequirementId = (int)discountRequirement,
RequirementSpentAmount = requirementSpentAmount,
RequirementBillingCountryIs = requirementBillingCountryIs,
RequirementShippingCountryIs = requirementShippingCountryIs,
DiscountLimitationId = (int)discountLimitation,
LimitationTimes = limitationTimes,
Name = name,
UsePercentage = usePercentage,
DiscountPercentage = discountPercentage,
DiscountAmount = discountAmount,
StartDate = discountStartDate,
EndDate = discountEndDate,
RequiresCouponCode = requiresCouponCode,
CouponCode = couponCode
};
this.DiscountService.InsertDiscount(discount);
now my task is that in 'CouponCode = couponCode'
i have to replace this coupon code from excel sheet column which is uploaded by client when he save the discount.
and this excel sheet can have 50000 coupon codes so each coupon have the same info of discount .
in this solution we have entity framework. and we have to store the data in this format
D1 10% C1(coupon code from excel sheet)
D1 10% C2(coupon code from excel sheet)
D1 10% C3(coupon code from excel sheet)
D1 10% C4(coupon code from excel sheet)
D1 10% C5(coupon code from excel sheet)
D1 10% C6(coupon code from excel sheet)
D1 10% C7(coupon code from excel sheet)
if (fuXlsFile.PostedFile != null && !String.IsNullOrEmpty(fuXlsFile.FileName))
{
DataTable dt = GetDataFromExcel(filePath, "Sheet1");
foreach (DataRow dr in dt.Rows)
{
discount = new Discount()
{
DiscountTypeId = (int)discountType,
DiscountRequirementId = (int)discountRequirement,
RequirementSpentAmount = requirementSpentAmount,
RequirementBillingCountryIs = requirementBillingCountryIs,
RequirementShippingCountryIs = requirementShippingCountryIs,
DiscountLimitationId = (int)discountLimitation,
LimitationTimes = limitationTimes,
Name = name,
UsePercentage = usePercentage,
DiscountPercentage = discountPercentage,
DiscountAmount = discountAmount,
StartDate = discountStartDate,
EndDate = discountEndDate,
RequiresCouponCode = requiresCouponCode,
CouponCode = dr[0].ToString()
};
this.DiscountService.InsertDiscount(discount);
}
}
i found the way to deal with this situation in this way.still i have to loop each record but i think this is the necessity of my work.