Exemple #1
0
        public virtual CouponStore UpdateCouponStore(CouponStore entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            CouponStore other = GetCouponStore(entity.CouponId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update CouponStore set  [ID]=@ID
							, [StoreID]=@StoreID
							, [CreatedOn]=@CreatedOn 
							 where CouponID=@CouponID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@CouponID", entity.CouponId)
                , new SqlParameter("@ID", entity.Id)
                , new SqlParameter("@StoreID", entity.StoreId)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetCouponStore(entity.CouponId));
        }
Exemple #2
0
        public virtual CouponStore InsertCouponStore(CouponStore entity)
        {
            CouponStore other = new CouponStore();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into CouponStore ( [CouponID]
				,[ID]
				,[StoreID]
				,[CreatedOn] )
				Values
				( @CouponID
				, @ID
				, @StoreID
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@CouponID", entity.CouponId)
                    , new SqlParameter("@ID", entity.Id)
                    , new SqlParameter("@StoreID", entity.StoreId)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetCouponStore(Convert.ToInt32(identity)));
            }
            return(entity);
        }
Exemple #3
0
        public void CouponStore_EmptyHasZeroDiscount()
        {
            var couponStore = new CouponStore();

            Assert.Equal(0, couponStore.TotalDiscount(new List <ItemBase>()
            {
            }));
        }
Exemple #4
0
        public void CouponStore_Add_CouponDoesNotApply()
        {
            var couponStore = new CouponStore();

            couponStore.Add(new BxGyCoupon()
            {
                itemName = "does_not_exist",
                X        = 1,
                Y        = 1
            });
            Assert.Equal(0, couponStore.TotalDiscount(SingleQuantityList(2, 1)));
        }
Exemple #5
0
        public void CouponStore_Add_SingleCoupon()
        {
            var couponStore = new CouponStore();

            couponStore.Add(new BxGyCoupon()
            {
                itemName = "foo",
                X        = 1,
                Y        = 1
            });
            Assert.Equal(1, couponStore.TotalDiscount(SingleQuantityList(2, 1)));
        }
Exemple #6
0
        public virtual CouponStore CouponStoreFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            CouponStore entity = new CouponStore();

            entity.Id        = (System.Int32)dr["ID"];
            entity.CouponId  = (System.Int32)dr["CouponID"];
            entity.StoreId   = (System.Int32)dr["StoreID"];
            entity.CreatedOn = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
Exemple #7
0
        public void CouponStore_Add_MultipleCouponsDifferentOrder()
        {
            var couponStore = new CouponStore();

            couponStore.Add(new PercentOffCoupon()
            {
                percent = 10,
            });
            couponStore.Add(new BxGyCoupon()
            {
                itemName = "foo",
                X        = 1,
                Y        = 1
            });
            Assert.Equal(1.1m, couponStore.TotalDiscount(SingleQuantityList(2, 1)));
        }
Exemple #8
0
 public virtual CouponStore DeleteCouponStore(CouponStore entity)
 {
     this.DeleteCouponStore(entity.CouponId);
     return(entity);
 }
 public CouponStore InsertCouponStore(CouponStore entity)
 {
     return(_iCouponStoreRepository.InsertCouponStore(entity));
 }
 public CouponStore UpdateCouponStore(CouponStore entity)
 {
     return(_iCouponStoreRepository.UpdateCouponStore(entity));
 }