public ActionResult GetPromotionActivityListJson(Pagination pagination, string title, int status) { if (pagination.page == 0) { pagination.page = 1; } if (pagination.rows == 0) { pagination.rows = 100; } if (string.IsNullOrWhiteSpace(pagination.sidx)) { pagination.sidx = "CreateDateTime desc"; } pagination.sord = "asc"; RepositoryManager repository = new RepositoryManager(); List <SEGetPromotionActivityConfig> list = null; if (!string.IsNullOrWhiteSpace(title)) { Expression <Func <SEGetPromotionActivityConfig, bool> > exp = _ => _.ActivityName.Contains(title); list = repository.GetEntityList <SEGetPromotionActivityConfig>(exp, pagination); list?.Where(_ => { return(status == 1 ? (_.StartDateTime <= DateTime.Now && _.EndDateTime > DateTime.Now) : (status == 2 ? (_.EndDateTime <= DateTime.Now) : (_.EndDateTime > DateTime.Now))); }); } else { list = repository.GetEntityList <SEGetPromotionActivityConfig>(pagination); } PromotionActivityManager manager = new PromotionActivityManager(); if (list != null) { list.ForEach(_ => { _.StatusText = _.Status ? "启用" : "禁用"; _.NewUserText = _.IsNewUser ? "新用户" : "全部"; _.GetCouponNumbers = manager.GetCouponHad(_.ID.Value); var items = manager.GetEntity(_.ID.Value).CouponItems; if (items != null && items.Count() > 0) { _.GetCouponTotal = items.FirstOrDefault().Quantity; } _.GetCouponTotal = _.GetCouponTotal != null ? (_.GetCouponTotal - _.GetCouponNumbers) : null; _.Uri = HttpContext.Request.Headers["Host"].Contains(".cn") ? "https://wx.tuhu.cn/PromotionActivity/Coupon/" + _.ID + ".html" : "http://wx.tuhu.work/PromotionActivity/Coupon/" + _.ID + ".html"; _.Uri = string.Format("<a href=\"{0}\" target=\"_bank\" >{0}</a> ", _.Uri); }); } return(Content(JsonConvert.SerializeObject(new { total = pagination.records, rows = list }))); }
public ActionResult PromotionEdit(Guid?ID) { ViewBag.Count = 0; if (ID == null) { return(View()); } else { PromotionActivityManager manager = new PromotionActivityManager(); SE_GetPromotionActivityConfig model = manager.GetEntity(ID.Value); ViewBag.Count = manager.GetPromotionActivityCountByID(ID.Value); return(View(model)); } }