private long createCoupon( String title, String startDate, String endDate, int amount, CouponType type, String massage, double price) { System.out.println("creating coupon : " + title); Coupon coupon = new Coupon(); try { coupon.setStartDate(Utils.string2Date(startDate)); coupon.setEndDate(Utils.string2Date(endDate)); coupon.setTitle(title); coupon.setAmount(amount); coupon.setPrice(price); coupon.setType(type); coupon.setMassage(massage); String image = title + ".img"; coupon.setImage(image); compFacade.createCoupon(coupon); return coupon.getId(); } catch (Exception e) { logger.error("create coupons " + title + " failed : " + e.toString()); return 0; } }
private void updateCoupon(long couponId) { System.out.println("updating coupon with id : " + couponId); try { Coupon coupon = compFacade.getCoupon(couponId); coupon.setAmount(100); coupon.setPrice(coupon.getPrice() / 2); compFacade.updateCoupon(coupon); } catch (Exception e) { logger.error("updateCoupon failed : " + e.toString()); } }