/// <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")); }
public HttpResponseMessage Edit(CategoryModel model) { var couponCategory = _otherCouponCategoryService.GetCouponCategoryById(model.Id); couponCategory.Name = model.Name; couponCategory.Count = model.Count; couponCategory.Price = model.Price; couponCategory.ReMark = model.ReMark; couponCategory.BrandId = model.BrandId; if (_otherCouponCategoryService.UpdateCouponCategory(couponCategory)) { return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据修改成功"))); } return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据修改失败"))); }