/// <summary>
        /// Loads a Coupon object for the given coupon code
        /// </summary>
        /// <param name="couponCode">Coupon code for which to load the coupon</param>
        /// <returns>The Coupon object loaded</returns>
        public static Coupon LoadForCouponCode(string couponCode)
        {
            couponCode = couponCode.ToUpperInvariant();
            string key    = "Coupon_" + couponCode;
            Coupon coupon = ContextCache.GetObject(key) as Coupon;

            if (coupon != null)
            {
                return(coupon);
            }
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT CouponId");
            selectQuery.Append(" FROM ac_Coupons");
            selectQuery.Append(" WHERE CouponCode = @couponCode");
            selectQuery.Append(" AND StoreId = @storeId");
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@couponCode", System.Data.DbType.String, couponCode);
            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId);
            int couponId = AlwaysConvert.ToInt(database.ExecuteScalar(selectCommand));

            if (couponId != 0)
            {
                coupon = CouponDataSource.Load(couponId);
                ContextCache.SetObject(key, coupon);
                return(coupon);
            }
            return(null);
        }
示例#2
0
 public static Coupon Load(Int32 couponId)
 {
     return(CouponDataSource.Load(couponId, true));
 }
示例#3
0
 public static CouponCollection LoadForShipMethod(Int32 shipMethodId, string sortExpression)
 {
     return(CouponDataSource.LoadForShipMethod(shipMethodId, 0, 0, sortExpression));
 }
示例#4
0
 public static CouponCollection LoadForShipMethod(Int32 shipMethodId, int maximumRows, int startRowIndex)
 {
     return(CouponDataSource.LoadForShipMethod(shipMethodId, maximumRows, startRowIndex, string.Empty));
 }
示例#5
0
 public static CouponCollection LoadForProduct(Int32 productId, int maximumRows, int startRowIndex)
 {
     return(CouponDataSource.LoadForProduct(productId, maximumRows, startRowIndex, string.Empty));
 }
示例#6
0
 public static CouponCollection LoadForShipMethod(Int32 shipMethodId)
 {
     return(CouponDataSource.LoadForShipMethod(shipMethodId, 0, 0, string.Empty));
 }
示例#7
0
 public static CouponCollection LoadForProduct(Int32 productId)
 {
     return(CouponDataSource.LoadForProduct(productId, 0, 0, string.Empty));
 }
示例#8
0
 public static CouponCollection LoadForProduct(Int32 productId, string sortExpression)
 {
     return(CouponDataSource.LoadForProduct(productId, 0, 0, sortExpression));
 }
示例#9
0
 public static CouponCollection LoadForGroup(Int32 groupId, int maximumRows, int startRowIndex)
 {
     return(CouponDataSource.LoadForGroup(groupId, maximumRows, startRowIndex, string.Empty));
 }
示例#10
0
 public static CouponCollection LoadForGroup(Int32 groupId, string sortExpression)
 {
     return(CouponDataSource.LoadForGroup(groupId, 0, 0, sortExpression));
 }
示例#11
0
 public static CouponCollection LoadForGroup(Int32 groupId)
 {
     return(CouponDataSource.LoadForGroup(groupId, 0, 0, string.Empty));
 }
示例#12
0
 public static CouponCollection LoadForBasket(Int32 basketId, string sortExpression)
 {
     return(CouponDataSource.LoadForBasket(basketId, 0, 0, sortExpression));
 }
示例#13
0
 public static CouponCollection LoadForBasket(Int32 basketId)
 {
     return(CouponDataSource.LoadForBasket(basketId, 0, 0, string.Empty));
 }