예제 #1
0
        public static string GetMonthReport(int year)
        {
            string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            var      res    = new List <DataPoint>();
            var      list   = reportDAO.GetMonthReport(year).ToList();
            int      index  = 0;

            for (int i = 0; i < 12; i++)
            {
                if (index < list.Count && list[index].Month == i + 1)
                {
                    res.Add(new DataPoint(i + 1, list[index++].Total, months[i]));
                }
                else
                {
                    res.Add(new DataPoint(i + 1, 0, months[i]));
                }
            }
            return(JsonConvert.SerializeObject(res, jsonSetting));
        }