private bool Create() { int newID = 0; this.guid = Guid.NewGuid(); newID = DBCoupon.Create( this.siteID, this.couponCode, this.name, this.discount, this.discountType, this.orderPurchaseFrom, this.orderPurchaseTo, this.fromDate, this.expiryDate, this.minPurchase, this.limitationTimes, this.isActive, this.appliedType, this.appliedToProducts, this.appliedToCategories, this.guid, this.createdOn, this.discountQtyStep, this.maximumQtyDiscount); this.couponID = newID; return(newID > 0); }
public static bool ExistCode(int siteId, string couponCode) { using (IDataReader reader = DBCoupon.GetOneByCode(siteId, couponCode)) { if (reader.Read()) { return(true); } } return(false); }
public static Coupon GetOneByCode(int siteId, string couponCode) { using (IDataReader reader = DBCoupon.GetOneByCode(siteId, couponCode)) { if (reader.Read()) { Coupon coupon = new Coupon(); coupon.couponID = Convert.ToInt32(reader["CouponID"]); coupon.siteID = Convert.ToInt32(reader["SiteID"]); coupon.couponCode = reader["CouponCode"].ToString(); coupon.name = reader["Name"].ToString(); coupon.discount = Convert.ToDecimal(reader["Discount"]); coupon.discountType = Convert.ToInt32(reader["DiscountType"]); coupon.orderPurchaseFrom = Convert.ToDecimal(reader["OrderPurchaseFrom"]); coupon.orderPurchaseTo = Convert.ToDecimal(reader["OrderPurchaseTo"]); if (reader["FromDate"] != DBNull.Value) { coupon.fromDate = Convert.ToDateTime(reader["FromDate"]); } if (reader["ExpiryDate"] != DBNull.Value) { coupon.expiryDate = Convert.ToDateTime(reader["ExpiryDate"]); } coupon.minPurchase = Convert.ToDecimal(reader["MinPurchase"]); coupon.limitationTimes = Convert.ToInt32(reader["LimitationTimes"]); coupon.isActive = Convert.ToBoolean(reader["IsActive"]); coupon.appliedType = Convert.ToInt32(reader["AppliedType"]); coupon.appliedToProducts = reader["AppliedToProducts"].ToString(); coupon.appliedToCategories = reader["AppliedToCategories"].ToString(); coupon.guid = new Guid(reader["Guid"].ToString()); coupon.createdOn = Convert.ToDateTime(reader["CreatedOn"]); coupon.numOfUses = Convert.ToInt32(reader["NumOfUses"]); if (reader["DiscountQtyStep"] != DBNull.Value) { coupon.discountQtyStep = Convert.ToInt32(reader["DiscountQtyStep"]); } if (reader["MaximumQtyDiscount"] != DBNull.Value) { coupon.maximumQtyDiscount = Convert.ToInt32(reader["MaximumQtyDiscount"]); } return(coupon); } return(null); } }
private void GetCoupon(int couponId) { using (IDataReader reader = DBCoupon.GetOne(couponId)) { if (reader.Read()) { this.couponID = Convert.ToInt32(reader["CouponID"]); this.siteID = Convert.ToInt32(reader["SiteID"]); this.couponCode = reader["CouponCode"].ToString(); this.name = reader["Name"].ToString(); this.discount = Convert.ToDecimal(reader["Discount"]); this.discountType = Convert.ToInt32(reader["DiscountType"]); this.orderPurchaseFrom = Convert.ToDecimal(reader["OrderPurchaseFrom"]); this.orderPurchaseTo = Convert.ToDecimal(reader["OrderPurchaseTo"]); if (reader["FromDate"] != DBNull.Value) { this.fromDate = Convert.ToDateTime(reader["FromDate"]); } if (reader["ExpiryDate"] != DBNull.Value) { this.expiryDate = Convert.ToDateTime(reader["ExpiryDate"]); } this.minPurchase = Convert.ToDecimal(reader["MinPurchase"]); this.limitationTimes = Convert.ToInt32(reader["LimitationTimes"]); this.isActive = Convert.ToBoolean(reader["IsActive"]); this.appliedType = Convert.ToInt32(reader["AppliedType"]); this.appliedToProducts = reader["AppliedToProducts"].ToString(); this.appliedToCategories = reader["AppliedToCategories"].ToString(); this.guid = new Guid(reader["Guid"].ToString()); this.createdOn = Convert.ToDateTime(reader["CreatedOn"]); if (reader["DiscountQtyStep"] != DBNull.Value) { this.discountQtyStep = Convert.ToInt32(reader["DiscountQtyStep"]); } if (reader["MaximumQtyDiscount"] != DBNull.Value) { this.maximumQtyDiscount = Convert.ToInt32(reader["MaximumQtyDiscount"]); } } } }
private bool Update() { return(DBCoupon.Update( this.couponID, this.siteID, this.couponCode, this.name, this.discount, this.discountType, this.orderPurchaseFrom, this.orderPurchaseTo, this.fromDate, this.expiryDate, this.minPurchase, this.limitationTimes, this.isActive, this.appliedType, this.appliedToProducts, this.appliedToCategories, this.guid, this.createdOn, this.discountQtyStep, this.maximumQtyDiscount)); }
public static bool IsAvailable(int siteId, string zoneIds, string productIds) { return(DBCoupon.IsAvailable(siteId, zoneIds, productIds)); }
public static List <Coupon> GetPage(int siteId, int pageNumber, int pageSize) { IDataReader reader = DBCoupon.GetPage(siteId, pageNumber, pageSize); return(LoadListFromReader(reader)); }
public static int GetCount(int siteId) { return(DBCoupon.GetCount(siteId)); }
public static bool DeleteBySite(int siteId) { return(DBCoupon.DeleteBySite(siteId)); }
public static bool Delete(int couponId) { return(DBCoupon.Delete(couponId)); }