/// <summary> /// 初始化修改数据界面 /// </summary> /// <returns></returns> public ActionResult Update(int Id) { int adminId = AuthorityHelper.OperatorId ?? 0; Administrator admin = _administratorContract.Administrators.Where(x => x.Id == adminId).FirstOrDefault(); int count = admin.Roles.Where(x => x.Weight == 100).Count(); bool isShow = false; if (count > 0) { isShow = true; } ViewBag.IsShow = isShow; CouponDto dto = _couponContract.Edit(Id); admin = _administratorContract.Administrators.Where(x => x.Member.MemberName == dto.UniqueNum).FirstOrDefault(); string realName = string.Empty; if (admin != null) { realName = admin.Member.RealName; } int quantity = 0; if (dto.PartnerId != null) { Partner partner = _partnerContract.View(dto.PartnerId ?? 0); DateTime current = DateTime.Now; List <Coupon> listCoupon = partner.Coupons.Where(x => x.IsForever == true || (x.StartDate.CompareTo(current) <= 0 && x.EndDate.CompareTo(current) >= 0)).ToList(); foreach (Coupon coupon in listCoupon) { quantity = quantity + coupon.CouponItems.Where(x => x.IsUsed == false && x.MemberId == null).Count(); } if (partner.PartnerLevelId != null) { quantity = partner.PartnerLevel.CouponQuantity - quantity; } } ViewBag.Quantity = quantity; dto.RealName = realName; return(PartialView(dto)); }
/// <summary> /// 查看数据 /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult View(int Id) { var entity = _partnerContract.View(Id); return(PartialView(entity)); }