public JsonResult TypeChart()
        {
            var result = new ChartJSModel();
            int count  = 0;

            foreach (var type in _context.TicketType.ToList())
            {
                result.Labels.Add(type.Name);
                result.Data.Add(_context.Ticket.Where(t => t.TicketTypeId == type.Id).Count());
                if (count < 10)
                {
                    result.BackgroundColor.Add(_backgroundColors[count]);
                }
                else
                {
                    result.BackgroundColor.Add(_backgroundColors[(count % 10)]);
                }
                count++;
            }
            return(Json(result));
        }
        public JsonResult PriorityChart()
        {
            var result = new ChartJSModel();
            int count  = 0;

            foreach (var priority in _context.Priority.ToList())
            {
                result.Labels.Add(priority.Name);
                result.Data.Add(_context.Ticket.Where(t => t.PriorityId == priority.Id).Count());
                if (count < 11)
                {
                    result.BackgroundColor.Add(_backgroundColors[count]);
                }
                else
                {
                    result.BackgroundColor.Add(_backgroundColors[(count % 10)]);
                }
                count++;
            }
            return(Json(result));
        }
Пример #3
0
        public JsonResult StatusChart()
        {
            var result   = new ChartJSModel();
            var statuses = _context.TicketStatuses.ToList();
            int count    = 0;

            foreach (var status in statuses)
            {
                result.Labels.Add(status.Name);
                result.Data.Add(_context.Tickets.Where(t => t.TicketStatusId == status.Id).Count());

                if (count < 10)
                {
                    result.BackgroundColors.Add(_backgroundColors[count]);
                }
                else
                {
                    result.BackgroundColors.Add(_backgroundColors[count % 10]);
                }
                count++;
            }
            return(Json(result));
        }