public ActionResult verEstadisticas() { if (Request.Cookies["Sesion"] == null) { return RedirectToAction("Index", "Home"); } else { HttpCookie aCookie = Request.Cookies["Sesion"]; if (!aCookie["Tipo"].Equals("Coor")) return RedirectToAction("Index", "Home"); else ViewBag.Texto = Server.HtmlEncode(aCookie.Values["Usuario"]); } String tipoConsulta = Request["Estadistica"]; Asistentes_TutoresEntities db = new Asistentes_TutoresEntities(); if (tipoConsulta == "Carrera"){ ViewBag.GraphicName = "Asistencia por Carrera"; ViewBag.Creategraphic = 1; ViewData["Valor"] = "Carrera"; var result = db.SP_EstadisticasCarrera().ToArray(); var json = new JavaScriptSerializer().Serialize(result); ViewData["json"] = json; } else if (tipoConsulta == "Curso"){ ViewBag.GraphicName = "Asistencia por Curso"; ViewBag.Creategraphic = 1; ViewData["Valor"] = "Curso"; var result = db.SP_EstadisticasCurso().ToArray(); var json = new JavaScriptSerializer().Serialize(result); ViewData["json"] = json; } else if (tipoConsulta == "Tutor"){ ViewBag.GraphicName = "Asistencia por Tutor"; ViewBag.Creategraphic = 1; ViewData["Valor"] = "Tutor"; var result = db.SP_EstadisticasTutor().ToArray(); var json = new JavaScriptSerializer().Serialize(result); ViewData["json"] = json; } else if (tipoConsulta == "Fechas"){ ViewBag.GraphicName = "Asistencia por Rango de Fechas"; ViewBag.Creategraphic = 1; ViewData["Valor"] = "Fechas"; String fechaInicial = Request["dateStart"]; String fechaFinal = Request["dateEnd"]; ViewData["FI"] = Request["dateStart"]; ViewData["FF"] = Request["dateEnd"]; string format = "yyyy-MM-dd"; var result = db.SP_EstadisticasFechas(DateTime.Parse(Request["dateStart"]), DateTime.Parse(Request["dateEnd"])).ToArray(); List<Histograma> pointlist = new List<Histograma>(); foreach (var point in result) { Histograma p = new Histograma(); p.x = point.x.ToString(); p.date = point.Fecha.ToString(format); pointlist.Add(p); } var json = new JavaScriptSerializer().Serialize(pointlist); ViewData["json"] = json; System.Diagnostics.Debug.WriteLine(json); } else{ ViewBag.Creategraphic = 0; } return View(); }