/// <summary>
        /// 获取优惠券
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult OtherCouponOwn(int id)
        {
            if (_workContext.CurrentUser == null)
            {
                return(Redirect("http://www.iyookee.cn/#/user/login"));
            }
            var couponCategory = _otherCouponCategoryService.GetCouponCategoryById(id);
            var condition      = new OtherCouponSearchCondition
            {
                CouponCategoryId = id,
                Status           = 0
            };
            var coupon = _otherCouponService.GetCouponByCondition(condition).FirstOrDefault();

            if (coupon != null)
            {
                _otherCouponOwnerService.CreateRecord(_workContext.CurrentUser.Id, coupon.Id);
                coupon.Status = EnumOtherCouponStatus.Owned;
                _otherCouponService.Update(coupon);
                couponCategory.Count = couponCategory.Count - 1;
                _otherCouponCategoryService.UpdateCouponCategory(couponCategory);
                var brand     = _productBrandService.GetProductBrandById(couponCategory.BrandId);
                var couponOwn = new CouponCategoryModel
                {
                    Name      = couponCategory.Name,
                    Number    = coupon.Number,
                    BrandName = brand.Bname
                };
                return(View(couponOwn));
            }
            return(RedirectToAction("OtherCoupons", "OtherCoupons"));
        }
Esempio n. 2
0
        public HttpResponseMessage Detailed(int id)
        {
            var couponCategory = _otherCouponCategoryService.GetCouponCategoryById(id);

            return(PageHelper.toJson(couponCategory));
        }