Ejemplo n.º 1
0
        public void TestRegistroUsuario()
        {
            Conexion conn = new Conexion();

            if (conn.state() == true)
            {
                Registro_function registo = new Registro_function(conn);

                Assert.IsFalse(registo.valido("", "", "", "", "", "", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "", "", "", "", "", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "", "", "", "", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "avalos", "", "", "", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "avalos", "1/2/2020", "", "", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "avalos", "1/2/2020", "guatemala", "", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "avalos", "1/2/2020", "guatemala", "mixco", "", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "avalos", "1/2/2020", "guatemala", "mixco", "11122", "", ""));
                Assert.IsFalse(registo.valido("andreeavalos", "andree", "avalos", "1/2/2020", "guatemala", "mixco", "11122", "1/2/2020", ""));
                Assert.IsTrue(registo.valido("andreeavalos", "andree", "avalos", "1/2/2020", "guatemala", "mixco", "11122", "1/2/2020", "1/2/2020"));

                Assert.AreEqual(registo.insertar_registro("andreeavalos", "*****@*****.**", "carlos",
                                                          "andree", "avalos", "soto", "35385252", "1/2/2020", "guatemala", "mixco", "11122", "1/2/2020", "1/2/2020"), "Registro Exitoso");

                conn.close();
                return;
            }
            conn.close();
            Assert.Fail();
        }
Ejemplo n.º 2
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string user_name        = req.Query["user_name"];
            string email            = req.Query["email"];
            string primer_nombre    = req.Query["primer_nombre"];
            string segundo_nombre   = req.Query["segundo_nombre"];
            string primer_apellido  = req.Query["primer_apellido"];
            string segundo_apellido = req.Query["segundo_apellido"];
            string telefono         = req.Query["telefono"];
            string fecha_nacimiento = req.Query["fecha_nacimiento"];
            string pais             = req.Query["pais"];
            string ciudad           = req.Query["ciudad"];
            string password         = req.Query["pass"];
            string createdAt        = DateTime.Now.ToString("dd/MM/yyyy");
            string updatedAt        = DateTime.Now.ToString("dd/MM/yyyy");

            //string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            //dynamic data = JsonConvert.DeserializeObject(requestBody);
            //name = name ?? data?.name;

            Conexion conn            = new Conexion();
            string   responseMessage = "Conexion Fallida";

            if (conn.state() == true)
            {
                Registro_function registro = new Registro_function(conn);

                if (registro.valido(user_name, primer_nombre, primer_apellido, fecha_nacimiento, pais, ciudad, password, createdAt, updatedAt))
                {
                    responseMessage = registro.insertar_registro(user_name, email, primer_nombre, segundo_nombre, primer_apellido, segundo_apellido, telefono, fecha_nacimiento, pais, ciudad, password, createdAt, updatedAt);
                    conn.close();
                    return(new OkObjectResult(JsonConvert.SerializeObject(new response(true, responseMessage))));
                }
            }
            conn.close();
            return(new OkObjectResult(JsonConvert.SerializeObject(new response(false, responseMessage))));



            //string responseMessage = string.IsNullOrEmpty(name)
            //    ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
            //    : $"La conexion fue un: {conn}";

            //return new OkObjectResult(responseMessage);
        }