예제 #1
0
        public string GetChartData(int? idCentro = null, int? idMesa = null)
        {
            var db = new edayRoomEntities();
            var user = db.users.Single(u => u.username == User.Identity.Name);
            int interval = 30;
            if (idCentro != null)
            {
                interval = 5;
            }
            if (idMesa != null)
            {
                interval = 1;
            }
            var data = db.GetParticipacion(idCentro, idMesa, interval, user.id).ToList();
            var datos = new List<object>();
            var valorPrevio = 0;
            foreach (var d in data)
            {
                datos.Add(new
                                    {
                                        value = d.conteo - valorPrevio,
                                        participacion = d.conteo, d.cola,
                                        date = d.fecha,
                                        year = ((DateTime)d.fecha).Year,
                                        month = ((DateTime)d.fecha).Month - 1,
                                        day = ((DateTime)d.fecha).Day,
                                        hour = ((DateTime)d.fecha).Hour,
                                        min = ((DateTime)d.fecha).Minute
                                    });
                valorPrevio = (int)d.conteo;
            }

            return JsonConvert.SerializeObject(new
                            {
                                participacion = datos
                            }, Formatting.Indented);
        }