예제 #1
0
 public void ValidadTest()
 {
     Usuario user = new Usuario();
     user.passwd = "15827d1b83c6be8de449fa4535737d48";
     bool correct = user.validar("aaa111...");
     Assert.AreEqual(correct, true);
 }
예제 #2
0
 public void CrearAdminTest()
 {
     UserManager.CrearAdmin();
     Usuario user = new Usuario();
     user = UserManager.get("admin");
     Assert.IsNotNull(user);
     Assert.AreEqual(user.email, "*****@*****.**");
 }
예제 #3
0
        public static bool NuevoUsuario(Usuario u)
        {
            if (u == null) return false;

            using (MF0493Entities db = new MF0493Entities())
            {
                var data = from usuarios in db.Usuarios
                           where usuarios.username == u.username
                           select usuarios;

                if (data.Count() == 0)
                {
                    db.Usuarios.Add(u);
                    db.SaveChanges();
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
예제 #4
0
        public static void CrearAdmin()
        {
            using (MF0493Entities db = new MF0493Entities())
            {
                var data = from usuarios in db.Usuarios
                           where usuarios.username == "admin"
                           select usuarios;

                if (data.Count() == 0)
                {
                    Usuario u = new Usuario()
                    {
                        username = "******",
                        activo = true,
                        email ="*****@*****.**",
                        passwdSinCifrar = "aaa111..."
                    };
                    db.Usuarios.Add(u);
                    db.SaveChanges();
                }
            }
        }