public virtual CouponUsage UpdateCouponUsage(CouponUsage entity) { if (entity.IsTransient()) { return(entity); } CouponUsage other = GetCouponUsage(entity.CouponUsageId); if (entity.Equals(other)) { return(entity); } string sql = @"Update CouponUsage set [CustomerID]=@CustomerID , [CouponCode]=@CouponCode , [CreatedOn]=@CreatedOn where CouponUsageID=@CouponUsageID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@CouponUsageID", entity.CouponUsageId) , new SqlParameter("@CustomerID", entity.CustomerId) , new SqlParameter("@CouponCode", entity.CouponCode) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetCouponUsage(entity.CouponUsageId)); }
public virtual CouponUsage InsertCouponUsage(CouponUsage entity) { CouponUsage other = new CouponUsage(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into CouponUsage ( [CustomerID] ,[CouponCode] ,[CreatedOn] ) Values ( @CustomerID , @CouponCode , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@CouponUsageID", entity.CouponUsageId) , new SqlParameter("@CustomerID", entity.CustomerId) , new SqlParameter("@CouponCode", entity.CouponCode) , 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(GetCouponUsage(Convert.ToInt32(identity))); } return(entity); }
public void AddCouponUsage(long userId, long couponId) { var couponUsage = new CouponUsage { CouponId = couponId, UserId = userId }; _couponUsageRepository.Add(couponUsage); }
public virtual CouponUsage CouponUsageFromDataRow(DataRow dr) { if (dr == null) { return(null); } CouponUsage entity = new CouponUsage(); entity.CouponUsageId = (System.Int32)dr["CouponUsageID"]; entity.CustomerId = (System.Int32)dr["CustomerID"]; entity.CouponCode = dr["CouponCode"].ToString(); entity.CreatedOn = (System.DateTime)dr["CreatedOn"]; return(entity); }
public virtual CouponUsage DeleteCouponUsage(CouponUsage entity) { this.DeleteCouponUsage(entity.CouponUsageId); return(entity); }
public CouponUsage InsertCouponUsage(CouponUsage entity) { return(_iCouponUsageRepository.InsertCouponUsage(entity)); }
public CouponUsage UpdateCouponUsage(CouponUsage entity) { return(_iCouponUsageRepository.UpdateCouponUsage(entity)); }