예제 #1
0
        public ActionResult GetDataByDepartment()
        {
            Dictionary <string, List <RequestDetail> > detailDict = RequestDao.GetRequestDetailsByAllDepartments();
            List <object> data = new List <object>();

            foreach (KeyValuePair <string, List <RequestDetail> > kV in detailDict)
            {
                var count = kV.Value.Sum(rd => rd.Quantity);
                var obj   = new
                {
                    Department = kV.Key,
                    Amount     = count
                };
                data.Add(obj);
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }