Example #1
0
 public static Postulacion FindById(int id)
 {
     using (DesafioContext db = new DesafioContext())
     {
         return(db.Postulaciones.Where(x => x.PostulacionId == id).Include("Jugador").FirstOrDefault());
     }
 }
Example #2
0
 public static Partido FindById(int idPartido)
 {
     using (DesafioContext db = new DesafioContext())
     {
         return(db.Partidos.FirstOrDefault(x => x.PartidoId == idPartido));
     }
 }
Example #3
0
        public static List <Mensaje> FindByJugador(int idJugador)
        {
            try
            {
                using (DesafioContext db = new DesafioContext())
                {
                    var mensajes = db.Mensajes.Where(x => x.JugadorUno.JugadorId == idJugador || x.JugadorDos.JugadorId == idJugador)
                                   .Include(x => x.JugadorUno)
                                   .Include(x => x.JugadorDos);

                    if (mensajes != null)
                    {
                        return(mensajes.ToList());
                    }
                    else
                    {
                        return(new List <Mensaje>());
                    }
                }
            }
            catch
            {
                throw new Exception("Error al generar el Resultado del partido - Verifique los Datos");
            }
        }
Example #4
0
 public static void Add(Campeonato C)
 {
     using (DesafioContext db = new DesafioContext())
     {
         if (!db.Campeonatos.Contains(C))
         {
             db.Campeonatos.Add(C);
             db.SaveChanges();
         }
     }
 }
Example #5
0
 public static Jugador FindById(int Id)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             return(db.Jugadores.FirstOrDefault(x => x.JugadorId == Id));
         }
     }
     catch
     {
         return(null);
     }
 }
Example #6
0
 public static int CantidadDeJugadores()
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             return(db.Jugadores.Count());
         }
     }
     catch
     {
         return(-1);
     }
 }
Example #7
0
 public static Jugador FindfByEmail(string Email)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             return(db.Jugadores.FirstOrDefault(x => x.Email.ToLower() == Email.ToLower()));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al actualizar los datos -" + ex.Message);
     }
 }
Example #8
0
 public static void Add(Imagen imagen)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             db.Imagenes.Add(imagen);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #9
0
 public static bool TienePartido(int idJugador, DateTime fecha)
 {
     using (DesafioContext db = new DesafioContext())
     {
         var partidos = db.Partidos.Where(x => x.JugadorDesafiado.JugadorId == idJugador || x.JugadorDesafiante.JugadorId == idJugador);
         var partidosNoFinalizados = partidos.Where(x => x.Terminado == false);
         var partido = partidosNoFinalizados.Where(x => x.Fecha == fecha).FirstOrDefault();
         if (partido == null)
         {
             return(false);
         }
         return(true);
     }
 }
Example #10
0
 public static Jugador Logueo(string pEmail, string pPassword)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             return(db.Jugadores.FirstOrDefault(x => x.Email == pEmail && x.Password == pPassword));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Problemas con la conexion a la base de datos");
     }
 }
Example #11
0
 public static Campeonato FindById(int id)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             return(db.Campeonatos.FirstOrDefault(x => x.CampeonatoId == id));
         }
     }
     catch
     {
         throw new Exception("Error al Eliminar - Verifique los datos");
     }
 }
Example #12
0
 public static void Update(Postulacion p)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             db.Entry(p).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al Actualizar - Verifique los Datos" + ex.Message);
     }
 }
Example #13
0
 public static List <Postulacion> FindAllOrdenadasPorFecha(int idJugadorExcluido)
 {
     using (DesafioContext db = new DesafioContext())
     {
         var postulaciones = db.Postulaciones.Where(x => x.Jugador.JugadorId != idJugadorExcluido && x.Confirmada == false).OrderByDescending(x => x.Fecha).Include("Jugador");
         if (postulaciones != null)
         {
             return(postulaciones.ToList());
         }
         else
         {
             return(new List <Postulacion>());
         }
     }
 }
Example #14
0
 public static List <Partido> FindByJugadorCalificar(int id)
 {
     using (DesafioContext db = new DesafioContext())
     {
         var partidos = db.Partidos.Where(x => x.EstaComentado == false && x.JugadorDesafiado.JugadorId == id && x.JugadorDesafiante.JugadorId == id);
         if (partidos != null)
         {
             return(partidos.ToList());
         }
         else
         {
             return(new List <Partido>());
         }
     }
 }
Example #15
0
        /*public static List<Partido> FindUltimosPartidosByCategoria(int categoria)
         * {
         *  using (DesafioContext db = new DesafioContext())
         *  {
         *      var partidos = db.Partidos.OrderByDescending(x => x.Fecha).Where(x => x.JugadorDesafiado.Categoria.Id == categoria
         *                      && x.JugadorDesafiante.Categoria.Id == categoria && x.Terminado == true);
         *      if (partidos != null)
         *          return partidos.ToList();
         *      else
         *          return new List<Partido>();
         *  }
         * }*/

        public static List <Partido> FindByJugadorPendientes(int id)
        {
            using (DesafioContext db = new DesafioContext())
            {
                var partidos = db.Partidos.Where(x => x.JugadorDesafiado.JugadorId == id && x.JugadorDesafiante.JugadorId == id && x.Terminado == false && x.Cancelado == false);
                if (partidos != null)
                {
                    return(partidos.ToList());
                }
                else
                {
                    return(new List <Partido>());
                }
            }
        }
Example #16
0
 public static void MarcarComoLeido(int idMensaje)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Mensaje leido = db.Mensajes.FirstOrDefault(x => x.MensajeId == idMensaje);
             leido.Leido = true;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #17
0
 public static void Update(Partido p)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             db.Entry(p).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch
     {
         throw new Exception("Error al Actualizar - Verifique los Datos");
     }
 }
Example #18
0
 public static void Update(Campeonato c)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             db.Entry(c).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch
     {
         throw new Exception("Error al Actualizar resutlado - Verifique los Datos");
     }
 }
Example #19
0
 public static void Update(Jugador j)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             db.Entry(j).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch
     {
         throw new Exception("Error al actualizar los datos - Verifiquelos por favor");
     }
 }
Example #20
0
 public static void PartialUpdate(Jugador j, int categoriaId)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Jugador jugador = db.Jugadores.FirstOrDefault(x => x.Email == j.Email);
             db.Entry(jugador).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al actualizar los datos - " + ex.Message);
     }
 }
Example #21
0
 public static void Add(Partido p)
 {
     // cartel de aviso con las tareas pendientes (calificaciones y comentario).
     // amistoso libre, resultado opcional con calificacion obligatoria().
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             db.Partidos.Add(p);
             db.SaveChanges();
         }
     }
     catch
     {
         throw new Exception("Error al generar el Partido - Verifique los Datos");
     }
 }
Example #22
0
 public static void Delete(int id)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Imagen imagen = new Imagen {
                 ImagenId = id
             };
             db.Imagenes.Attach(imagen);
             db.Imagenes.Remove(imagen);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #23
0
 public static void Add(Jugador j)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             if (db.Jugadores.Where(x => x.Email == j.Email).Count() == 0)
             {
                 db.Jugadores.Add(j);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al Agregar el Jugador - Verifique los Datos");
     }
 }
Example #24
0
 public static void Delete(int id)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Campeonato c = db.Campeonatos.FirstOrDefault(x => x.CampeonatoId == id);
             if (c != null)
             {
                 db.Campeonatos.Remove(c);
                 db.SaveChanges();
             }
         }
     }
     catch
     {
         throw new Exception("Error al Eliminar - Verifique los datos");
     }
 }
Example #25
0
 public static void ConfirmarPostulacionEnPartido(int jugadorId, int postulacionId, string comentarioNuevo)
 {
     using (DesafioContext db = new DesafioContext())
     {
         Jugador     jugador     = db.Jugadores.FirstOrDefault(x => x.JugadorId == jugadorId);
         Postulacion postulacion = db.Postulaciones.FirstOrDefault(x => x.PostulacionId == postulacionId);
         Partido     P           = new Partido
         {
             JugadorDesafiante = postulacion.Jugador,
             JugadorDesafiado  = jugador,
             Fecha             = postulacion.Fecha,
             Lugar             = postulacion.Lugar,
             Comentario        = postulacion.Comentario + ". " + comentarioNuevo
         };
         postulacion.Confirmada = true;
         db.Partidos.Add(P);
         db.SaveChanges();
     }
 }
Example #26
0
 public static void Delete(int Id)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Jugador j = db.Jugadores.FirstOrDefault(x => x.JugadorId == Id);
             if (j != null)
             {
                 db.Jugadores.Remove(j);
                 db.SaveChanges();
             }
         }
     }
     catch
     {
         throw new Exception("Error al Eliminar al Juagador - Verifique los datos");
     }
 }
Example #27
0
 public static void Delete(int id)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Postulacion postulacion = db.Postulaciones.FirstOrDefault(x => x.PostulacionId == id);
             if (postulacion != null)
             {
                 db.Postulaciones.Remove(postulacion);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al Eliminar - Verifique los datos" + ex.Message);
     }
 }
Example #28
0
 public static void Delete(int idMensaje)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Mensaje mensaje = db.Mensajes.FirstOrDefault(x => x.MensajeId == idMensaje);
             if (mensaje != null)
             {
                 db.Mensajes.Remove(mensaje);
                 db.SaveChanges();
             }
         }
     }
     catch
     {
         throw new Exception("Error al generar el Resultado del partido - Verifique los Datos");
     }
 }
Example #29
0
 public static void Delete(int idPartido)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Partido partido = db.Partidos.FirstOrDefault(x => x.PartidoId == idPartido);
             if (partido != null)
             {
                 db.Partidos.Remove(partido);
                 db.SaveChanges();
             }
         }
     }
     catch
     {
         throw new Exception("Error al Eliminar - Verifique los datos");
     }
 }
Example #30
0
 public static void CambioPassword(string Email, string Password)
 {
     try
     {
         using (DesafioContext db = new DesafioContext())
         {
             Jugador j = db.Jugadores.FirstOrDefault(x => x.Email == Email);
             if (j != null)
             {
                 j.Password        = Password;
                 db.Entry(j).State = EntityState.Modified;
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception("Error al actualizar los datos -" + ex.Message);
     }
 }