public IActionResult Delete(int id)
        {
            CompetenciaContext context = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext;
            var competencia            = context.Eliminar(id);

            return(RedirectToAction("Index", "Competencia", new { id = id }));
        }
Beispiel #2
0
        public List <Deporte> listarDeportes(int idUsuario)
        {
            //Inicializamos un Set de deportes (los Set no permiten elementos repetidos
            HashSet <Deporte> listaDeportes = new HashSet <Deporte>();
            //inicializamos una lista de DeporteLugar
            List <DeporteLugar> listaDeporteLugares = new List <DeporteLugar>();
            //creamos el context
            CompetenciaContext context = new CompetenciaContext();

            try
            {
                //obtenemos la lista de DeporteLugar
                listaDeporteLugares.AddRange(context.DeporteLugar);

                //agregamos al set listaDeportes los deportes que haya utilizado el usuario en algun LugarDeRealizacion
                foreach (var deporteLugar in listaDeporteLugares)
                {
                    if (deporteLugar.LugarDeRealizacion.UsuarioId.Equals(idUsuario))
                    {
                        listaDeportes.Add(deporteLugar.Deporte);
                    }
                }

                //retornamos la lista de deportes
                return(listaDeportes.ToList());
            }
            catch (Exception)
            {
                throw new Exception("Error al Buscar Deporte en la Base de Datos");
            }
        }
        public IActionResult Detalles(int id)
        {
            CompetenciaContext context = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext;
            var competencia            = context.GetCompetencia(id);

            return(View(competencia));
        }
        public IActionResult Registrar(int idc, int idp, float puntaje)
        {
            CompetenciaContext context = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext;
            var competencia            = context.RegistrarResultados(idc, idp, puntaje);

            return(RedirectToAction("Detalles", "Competencia", new { id = idc }));
        }
        public IActionResult Index()
        {
            CompetenciaContext context = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext;
            var competencias           = context.getCompetencias();

            return(View(competencias));
        }
        public IActionResult Nuevo(int selectEvento, string inputNombre, string inputDescripcion, int selectUbicacion, string inputFecha, string inputHora, List <int> selectParticipantes)
        {
            CompetenciaContext context = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext;
            bool result = context.Add1(selectEvento, inputNombre, inputDescripcion, selectUbicacion, inputFecha, inputHora);

            if (result == true)
            {
                int id = context.lastInserted();
                result = context.Add2(id, selectParticipantes);
                return(RedirectToAction("Nuevo", "Competencia", new { result = "Success" }));
            }
            return(RedirectToAction("Nuevo", "Competencia", new { result = "Fail" }));
        }
Beispiel #7
0
 public Usuario buscarPorId(int id)
 {
     try
     {
         //creamos el context
         CompetenciaContext context = new CompetenciaContext();
         //retornamos el usuario con esa Id
         return(context.Usuario.Where(u => u.UsuarioId == id).FirstOrDefault());
     }
     catch (Exception)
     {
         throw new Exception("Error al buscar el usuario en la Base de Datos");
     }
 }
Beispiel #8
0
        public IActionResult Evento(int id)
        {
            EventoContext      context  = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext;
            CompetenciaContext context1 = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext;
            PartidoContext     context2 = HttpContext.RequestServices.GetService(typeof(PartidoContext)) as PartidoContext;
            List <Partido>     partidos = context2.getPartidos();

            partidos = partidos.Where(x => x.evento.id == id).ToList();
            List <Competencia> competencias = context1.getCompetencias();

            competencias         = competencias.Where(x => x.evento.id == id).ToList();
            ViewBag.Evento       = context.detallesEvento(id);
            ViewBag.Partidos     = partidos;
            ViewBag.Competencias = competencias;
            return(View());
        }
 public List <Login> buscarPorCorreo(string user)
 {
     try
     {
         //creamos el context
         var context = new CompetenciaContext();
         //buscamos los login que coinciden con el correoElectronico
         List <Login> log = context.Login.Where(l => l.correoElectronico == user).ToList();
         //retornamos la lista de logins
         return(log);
     }
     catch (Exception)
     {
         throw new Exception("Error al buscar el Correo en la Base de Datos");
     }
 }