Beispiel #1
0
        public JsonResult GetOrderList(int page, int limit, string id, string phone, string createTime)
        {
            var data = _manager.QueryAllOrder(true);

            if (!string.IsNullOrEmpty(id))
            {
                var iD = Guid.Parse(id.ToString().Trim());
                data = data.Where(m => m.Id.Equals(iD));
            }

            if (!string.IsNullOrEmpty(phone))
            {
                data = data.Where(m => m.Phone.Equals(phone));
            }

            if (!string.IsNullOrEmpty(createTime))
            {
                var time = DateTime.Parse(createTime);
                data = data.Where(m => m.CreateTime > time);
            }

            var dataCount = data.Count();
            var newData   = data.ToList().Skip((page - 1) * limit).Take(limit);


            var jsonResult = new
            {
                code  = 0,
                count = dataCount,
                data  = newData
            };

            return(Json(jsonResult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Index()
        {
            var data = _manager.QueryAllOrder(false)
                       .GroupBy(m => new { m.CreateTime.Month })
                       .Select(m => new
            {
                month = m.Key,
                total = m.Sum(x => x.TotalPrice)
            });
            List <string> nameList          = new List <string>();
            List <int>    countList         = new List <int>();
            Dictionary <string, object> dic = new Dictionary <string, object>();

            foreach (var item in data)
            {
                nameList.Add(item.month + "月");
                countList.Add(Convert.ToInt32(item.total));
            }
            dic.Add("list1", nameList);
            dic.Add("list2", countList);
            return(Json(dic));
        }