예제 #1
0
        public ActionResult GraficoDeportistas()
        {
            DeportistaNegocio control     = new DeportistaNegocio();
            List <Deportista> deportistas = control.ObtenerDeportistas(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            var deportistasPorAnyo = deportistas.GroupBy(p => p.FechaNacimiento.Year).Select(p => new { Year = p.Key, Cantidad = p.Count() });
            var datosGrafico       = "[";

            if (deportistasPorAnyo.Count() > 0)
            {
                foreach (var valor in deportistasPorAnyo)
                {
                    datosGrafico += "['" + valor.Year + "', " + valor.Cantidad + "],";
                }
                datosGrafico  = datosGrafico.Substring(0, datosGrafico.Length - 1);
                datosGrafico += "]";
            }
            else
            {
                datosGrafico = "[]";
            }

            ViewBag.DatosGrafico = datosGrafico;
            return(View());
        }
예제 #2
0
        //
        // GET: /Reporte/

        public ActionResult ListadoDeportistas()
        {
            DeportistaNegocio control     = new DeportistaNegocio();
            List <Deportista> deportistas = control.ObtenerDeportistas(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);

            return(View(deportistas));
        }
예제 #3
0
        public ActionResult Crear(Deportista deportista)
        {
            var tiposDocumento = new List <SelectListItem>();

            tiposDocumento.Add(new SelectListItem()
            {
                Text  = "Cédula de Ciudadanía",
                Value = "1"
            });
            tiposDocumento.Add(new SelectListItem()
            {
                Text  = "Tarjeta de Identidad",
                Value = "2"
            });
            ViewBag.TiposDocumento = tiposDocumento;

            DeportistaNegocio deportistaNegocio = new DeportistaNegocio();

            Entidades.Deportista nuevoDeportista = new Entidades.Deportista()
            {
                FechaNacimiento = deportista.FechaNacimiento.Value,
                NumeroDocumento = deportista.NumeroDocumento,
                PrimerApellido  = deportista.PrimerApellido,
                PrimerNombre    = deportista.PrimerNombre,
                SegundoNombre   = deportista.SegundoNombre,
                SegundoApellido = deportista.SegundoApellido,
                Sexo            = new Entidades.Sexo()
                {
                    Id = deportista.Genero == "M" ? 1 : 2
                },
                TipoDocumento = new Entidades.TipoDocumento()
                {
                    Id = int.Parse(deportista.TipoDocumento)
                }
            };
            try
            {
                deportistaNegocio.IngresarDeportista(nuevoDeportista);
                ViewBag.Mensaje = "Se ingresó el deportista";
            }
            catch (Exception exc)
            {
                ViewBag.Mensaje = "No se pudo ingresar el deportista";
                //Log.Error(exc);
            }
            return(View());
        }