Esempio n. 1
0
 public static bool  Validar(Usuario usuario)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var registro = context.Users.Single(r => r.UserGame == usuario.Nombre);
         if (registro.Password.Replace(" ", "") == usuario.Contrasena)
         {
             if (registro.State == 0)
             {
                 usuario.Estado = 1;
                 usuario.Turno  = context.Users.Where(r => r.State == 1).ToList().Count + 1;
                 MapToDatos(usuario, ref registro);
                 context.SaveChanges();
                 return(true);
             }
             else
             {
                 throw new Exception("Usuario ya loggeado");
             }
         }
         else
         {
             throw new Exception("Usuario o Contrasena Incorrectos");
         }
     }
     return(false);
 }
Esempio n. 2
0
 public static bool Jugar(Usuario usuario)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var gamers = context.Users.Where(r => r.State == 2).ToList();
         if (gamers.Count < 2)
         {
             var user = context.Users.Single(r => r.UserGame == usuario.Nombre);
             usuario.Estado = 2;
             var Gamers = context.Users.Where(r => r.State == 2).ToList();
             if (Gamers.Count == 0)
             {
                 usuario.Turno = 1;
             }
             else
             {
                 usuario.Turno = 1;
                 if (Gamers[0].Ingreso == 1)
                 {
                     usuario.Turno = 2;
                 }
             }
             MapToDatos(usuario, ref user);
             context.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
 public static bool updateJugador(elementGame usuario)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var registro = context.Game.Single(r => r.Id == usuario.Id);
         MapToDatos(usuario, ref registro);
         context.SaveChanges();
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
 public static void aumentarPuntuacion(Usuario usuario)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var registro = context.Users.Single(r => (r.UserGame != usuario.Nombre) && (r.State == 2));
         {
             registro.Points++;
             context.SaveChanges();
         }
     }
 }
Esempio n. 5
0
 public static int Cerrar(Usuario usuario)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var registro = context.Users.Single(r => r.UserGame == usuario.Nombre);
         {
             usuario.Estado = 0;
             int turno = (int)registro.Ingreso;
             MapToDatos(usuario, ref registro);
             context.SaveChanges();
             return(turno);
         }
     }
 }
Esempio n. 6
0
 public static bool ValidarAdmin(Usuario usuario)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var registro = context.Users.Single(r => r.UserGame == usuario.Nombre);
         if (registro.TypeUser.Replace(" ", "") == "Admin")
         {
             usuario.Estado = 3;
             MapToDatos(usuario, ref registro);
             context.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
Esempio n. 7
0
 public static void actualizarTurno(int turno)
 {
     using (var context = new Datos.JuegoEntities1())
     {
         var dbr = context.Users.Where(r => r.State == 1).ToList();
         for (int i = 0; i < dbr.Count; i++)
         {
             if (dbr[i].Ingreso > turno)
             {
                 dbr[i].Ingreso--;
             }
         }
         context.SaveChanges();
     }
 }