示例#1
0
        public IActionResult Post([FromBody] auxiliar value, int id)
        {
            Respuesta resp = new Respuesta();

            resp.status = "Error";
            resp.data   = null;
            try
            {
                using (DB_A6ED12_testmototekDBContext db = new DB_A6ED12_testmototekDBContext())
                {
                    SqlParameter[] sqlParams = new SqlParameter[]
                    {
                        new SqlParameter("@CORREO", value.key1),
                        new SqlParameter("@PASS", value.key2),
                    };
                    Usuario data = db.Usuarios.FromSqlRaw("Select * from Usuarios where Correo = @CORREO AND Contrasena = @PASS", sqlParams)
                                   .FirstOrDefault();
                    resp.status  = "Ok";
                    resp.message = "Success";
                    resp.data    = data;
                    return(Ok(resp));
                }
            }
            catch (Exception message)
            {
                resp.message = message.Message;
                return(BadRequest(resp));
            }
        }
示例#2
0
        public IActionResult Post([FromBody] auxiliar value)
        {
            Respuesta resp = new Respuesta();

            resp.status = "Error";
            resp.data   = null;
            try
            {
                using (DB_A6ED12_testmototekDBContext db = new DB_A6ED12_testmototekDBContext())
                {
                    var     idSearch = new SqlParameter("Id", value.key1);
                    Usuario data     = db.Usuarios.FromSqlRaw("Select * from Usuarios where Correo = @Id", idSearch)
                                       .FirstOrDefault();
                    resp.status  = "Ok";
                    resp.message = "Success";
                    resp.data    = data;
                    return(Ok(resp));
                }
            }
            catch (Exception message)
            {
                resp.message = message.Message;
                return(BadRequest(resp));
            }
        }
        public ActionResult Fabula()
        {
            var win = 0;

            ViewBag.Message = "Comienza la carrera de 100 metros entre la tortuga y la liebre";
            System.Diagnostics.Debug.WriteLine("Comienza la carrera de 100 metros entre la tortuga y la liebre");

            var liebre = new Liebre(new Animal()
            {
                nombre = "Liebre", durmiendo = false, llegoMeta = false
            });
            var tortuga = new Tortuga(new Animal()
            {
                nombre = "Tortuga", durmiendo = false, llegoMeta = false
            });

            tortuga.carrera();
            liebre.carrera();

            while (!tortuga.getLlego() || !liebre.getLlego())
            {
                if (tortuga.getLlego())
                {
                    System.Diagnostics.Debug.WriteLine("La tortuga gano...¡¡");
                    win = 1;
                    liebre.Detener();
                    break;
                }
                if (liebre.getLlego())
                {
                    System.Diagnostics.Debug.WriteLine("La liebre gano gano...¡¡");
                    win = 2;
                    tortuga.Detener();
                    break;
                }

                if (liebre.DistanciaT == tortuga.DistanciaT)
                {
                    if (!liebre.getDuerme() && liebre.DistanciaT != 1)
                    {
                        System.Diagnostics.Debug.WriteLine("La tortuga muerde a la liebre");
                        Thread.Sleep(500);
                    }
                }
            }

            if (tortuga.getLlego() && liebre.getLlego())
            {
                Random r = new Random();
                if (r.Next(1, 2) == 1)
                {
                    win = 3;
                    System.Diagnostics.Debug.WriteLine("La carrera ah sido un empate");
                }
                else
                {
                    win = 4;
                    System.Diagnostics.Debug.WriteLine("la tortuga gano..¡¡ fue chance");
                }
            }
            while (tortuga.isAlive() && liebre.isAlive())
            {
            }
            auxiliar a     = new auxiliar(tortuga.Pos, liebre.Pos, win);
            var      model = a.obtenetModelo();

            for (int i = 0; i < 50; i++)
            {
                // System.Diagnostics.Debug.WriteLine(model[1, i]);
            }
            //System.Diagnostics.Debug.WriteLine(model[2, 0]);
            return(View(model));
        }
示例#4
0
文件: Cast256.cs 项目: EvaMC/SegTI
        internal int distanciaHamming(ref BETA pData1 , ref BETA pData2)
        {
            int dist = 0;

            //Usamos la funcion completarString
            /*Console.WriteLine("TEXTO CIFRADO");
            Console.WriteLine("1.1__"+pData1.A+"  "+pData1.B+"  "+pData1.C+"  "+pData1.D);
            Console.WriteLine("2.1__"+pData2.A+"  "+pData2.B+"  "+pData2.C+"  "+pData2.D);*/

            res1 = completaString(ref pData1);
            res2 = completaString(ref pData2);

            /*Console.WriteLine("TRAS COMPLETAR STRINGS");
            Console.WriteLine("1.2__"+res1.A+"  "+res1.B+"  "+res1.C+"  "+res1.D);
            Console.WriteLine("2.2__"+res2.A+"  "+res2.B+"  "+res2.C+"  "+res2.D);*/

            return dist = calcularDist(ref res1,ref res2);
        }
示例#5
0
文件: Cast256.cs 项目: EvaMC/SegTI
        internal int calcularDist(ref auxiliar res1,ref auxiliar res2)
        {
            int dist = 0;

            aux1.A = res1.A.ToString();
            aux1.B = res1.B.ToString();
            aux1.C = res1.C.ToString();
            aux1.D = res1.D.ToString();

            aux2.A = res2.A.ToString();
            aux2.B = res2.B.ToString();
            aux2.C = res2.C.ToString();
            aux2.D = res2.D.ToString();

            for (int i = 0; i < 10; i++)
            {
                if (aux1.A[i] != aux2.A[i])
                    dist += 1;
            }
            for (int j = 0; j < 10; j++)
            {
                if (aux1.A[j] != aux2.A[j])
                    dist += 1;
            }

            for (int k = 0; k < 10; k++)
            {
                if (aux2.C[k] != aux1.C[k])
                    dist += 1;
            }

            for (int l = 0; l < 10; l++)
            {
                //Console.WriteLine(aux2.B.Length+"     "+l+ "   "+aux2.B[l]+" | "+aux1.B[l]);

                if (aux2.B[l] != aux1.B[l])
                    dist += 1;
            }

            for (int m = 0; m < 10; m++)
            {
                if (aux1.D[m] != aux2.D[m])
                    dist += 1;
            }

            return dist;
        }