//0元购活动配置 public ActionResult ZAConfigure(int pageIndex = 1, int pageSize = 10) { var result = ZeroActivityManager.SelectZeroActivityDetail(); var totalpage = result.Count * 1.0 / pageSize; if (totalpage - (int)totalpage == 0) { ViewBag.TotalCount = (int)totalpage; } else { ViewBag.TotalCount = (int)totalpage + 1; } ViewBag.CurrentPage = pageIndex; result = result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(); return(View(result)); }
public JsonResult UpsertZeroActivity(string productId, string variantId, string des, DateTime start, DateTime end, string imgUrl, int period = 0, int successQuota = 0, int quantity = 0) { var msg = string.Empty; if (start != null && end != null && start > end) { return(Json(new { status = "fail", msg = "日期选择错误" }, JsonRequestBehavior.AllowGet)); } var details = ZeroActivityManager.SelectZeroActivityDetail(); if (start > details.Where(o => !o.Period.Equals(period)).OrderByDescending(_ => _.EndDateTime).Select(x => x.EndDateTime).FirstOrDefault()) { return(Json(new { status = "fail", msg = "活动时间有间断" }, JsonRequestBehavior.AllowGet)); } ZeroActivityDetail data = new ZeroActivityDetail() { Period = period, ProductID = productId, VariantID = variantId, Description = des, StartDateTime = start, EndDateTime = end, SucceedQuota = successQuota, Quantity = quantity, ImgUrl = imgUrl }; var result = ZeroActivityManager.ZAConfigureAct(data) > 0; if (result) { return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "fail", msg = "操作失败" }, JsonRequestBehavior.AllowGet)); } }