public static CouponActionStatus AddCoupon(CouponInfo coupon) { CouponDao couponDao = new CouponDao(); try { if (couponDao.ExiCouponName(coupon.CouponId, coupon.CouponName)) { return(CouponActionStatus.DuplicateName); } if (couponDao.Add(coupon, null) > 0) { return(CouponActionStatus.Success); } return(CouponActionStatus.UnknowError); } catch (Exception) { return(CouponActionStatus.UnknowError); } }
private static CouponActionStatus AddCouponItem(CouponItemInfo couponItemInfo) { CouponDao couponDao = new CouponDao(); try { if (couponItemInfo.RedEnvelopeId.HasValue) { WeiXinRedEnvelopeInfo weiXinRedEnvelopeInfo = new WeiXinRedEnvelopeDao().Get <WeiXinRedEnvelopeInfo>(couponItemInfo.RedEnvelopeId.Value); IList <CouponItemInfo> sendedCouponInfoList = couponDao.GetSendedCouponInfoList(couponItemInfo.RedEnvelopeId.Value); if (weiXinRedEnvelopeInfo.MaxNumber <= sendedCouponInfoList.Count()) { return(CouponActionStatus.InadequateInventory); } } return((couponDao.Add(couponItemInfo, null) <= 0) ? CouponActionStatus.UnknowError : CouponActionStatus.Success); } catch (Exception ex) { Globals.WriteExceptionLog(ex, null, "Exception"); return(CouponActionStatus.UnknowError); } }