Пример #1
0
        /// <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"));
        }
Пример #2
0
        public HttpResponseMessage Edit(OtherCouponModel model)
        {
            var coupon = _otherCouponService.GetCouponById(model.Id);

            coupon.Number           = model.Number;
            coupon.Price            = model.Price;
            coupon.Status           = model.Status;
            coupon.CouponCategoryId = model.CouponCategoryId;
            if (_otherCouponService.Update(coupon) != null)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功")));
            }
            return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败")));
        }