コード例 #1
0
ファイル: ProductController.cs プロジェクト: jilter/project
        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));
            }
        }
コード例 #2
0
        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));
            }
        }