public ActionResult GetFree() { int totalCount = 0; List <FreeProduct> freeList = FreeProductService.GetList(100, 1, out totalCount); if (freeList.Count > 0) { var objList = new List <object>(); foreach (var item in freeList) { objList.Add(new { id = item.ID, name = item.Name, imgs = item.ImgUrls.Split('|'), count = item.Count, time = item.AddedTime.Value.ToString("MM/dd 23:59") }); } return(Json(new { code = 0, result = objList }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = 0, result = new { } }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFreeDetail(long userid, int freeid) { var product = FreeProductService.GetInfo(freeid); var frecordToday = FreeRecordService.GetTodayRecord(userid); var frecord = FreeRecordService.GetInfo(userid, freeid); if (product != null) { var obj = new { id = product.ID, name = product.Name, imgs = product.ImgUrls.Split('|'), desc = product.Desc, count = product.Count, remain = product.RQty, isget = frecord != null, isgetother = frecordToday != null, status = product.Status, time = product.AddedTime.Value.ToString("MM/dd 23:59") }; return(Json(new { code = 0, data = obj }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = 1, msg = "赠品不存在" }, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFreeList(int page = 1, int size = 20) { int totalPage = 0; int totalCount = 0; List <FreeProduct> freeList = FreeProductService.GetList(size, page, out totalCount); if (freeList.Count > 0) { totalPage = totalCount % size == 0 ? Convert.ToInt16(totalCount / size) : Convert.ToInt16(totalCount / size) + 1; var objList = new List <object>(); foreach (var item in freeList) { objList.Add(new { id = item.ID, name = item.Name, img = item.ImgUrls.Split('|')[0], count = item.Count, remain = item.RQty, time = item.AddedTime.Value.ToString("MM/dd 23:59") }); } return(Json(new { code = 0, data = objList, total = totalPage }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { code = 0, data = new List <FreeProduct>(), total = totalPage }, JsonRequestBehavior.AllowGet)); } }
// GET: Free public ActionResult Index(int pageIndex = 1, int pageSize = 20) { int totalCount = 0; var productList = FreeProductService.GetAllList(pageSize, pageIndex, out totalCount); ViewBag.PageCount = totalCount % pageSize == 0 ? (int)totalCount / pageSize : (int)totalCount / pageSize + 1; ViewBag.PageIndex = pageIndex; return(View(productList)); }
public ActionResult Delete(string ids) { string[] idArr = ids.Split(','); if (idArr.Length > 0) { foreach (var s in idArr) { FreeProductService.Delete(Convert.ToInt32(s)); } } return(Json(new { code = 0 }, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(FreeProduct p) { if (p.ID > 0) { int result = FreeProductService.Update(p); } else { p.AddedTime = DateTime.Now; p.ID = FreeProductService.Add(p); } return(Content("<script>alert('操作成功');window.location.href='" + Url.Content("~/Free/Add?id=") + p.ID + "';</script>")); }
public ActionResult Add(int?id) { FreeProduct p = new FreeProduct(); if (id.HasValue && id > 0) { p = FreeProductService.GetInfo(id.Value); if (p == null) { p = new FreeProduct(); } } return(View(p)); }
public ActionResult DeleteDisable() { int result = FreeProductService.DeleteDisable(); return(Json(new { code = 0, data = result }, JsonRequestBehavior.AllowGet)); }