コード例 #1
0
        public void OnPost()
        {
            Coupon aCoupon = new Coupon();

            aCoupon.UserId  = userID; // Connects the created coupon to the current users ID //
            aCoupon.Info    = "This coupon can be redeemed in the cafeteria for a free sandwich";
            aCoupon.Barcode = "570020010042069";

            int counter = _couponService.GetCouponCount(userID);

            if (counter < 10)
            {
                counter = counter + 1;
                _couponService.AddCouponCount(userID, counter);
            }

            if (counter == 10)
            {
                _couponService.CreateCoupon(aCoupon);
                _couponService.AddCouponCount(userID, 0);
            }

            Coupons        = _couponService.GetUserCoupons(userID);
            count          = counter;
            FaresLeft      = FaresLeft - counter;
            ProfilePicture = _iPicture.GetProfilePicture(userID);
        }