コード例 #1
0
        public List <PricePairModel> ApplyCoupon(List <PricePairModel> pricePairs, string couponCode)
        {
            if (String.IsNullOrEmpty(couponCode))
            {
                return(pricePairs);
            }

            var couponCore = new CouponCore(dc, config);
            var coupon     = couponCore.GetCouponByCode(couponCode);

            if (coupon != null)
            {
                var p = pricePairs.First(x => x.Base == "VC");

                if (coupon.PercentageOff > 0)
                {
                    p.Amount = p.Amount * (1 - coupon.PercentageOff);
                }
                else
                {
                    p.Amount = coupon.Amount;
                }
            }

            return(pricePairs);
        }
コード例 #2
0
ファイル: CouponController.cs プロジェクト: voicecoin/ICO-API
        public IActionResult ValidateCouponCode([FromRoute] string code)
        {
            var couponCore = new CouponCore(dc, Database.Configuration);

            bool existed = couponCore.GetCouponByCode(code) != null;

            return(Ok(existed));
        }