예제 #1
0
        public ActionResult Index(Int32 id)
        {
            TUniverso u = db.TUniverso.Find(id);

            ViewBag.universo  = u.NombUniverso;
            ViewBag.problemas =
                db.TProblema.Include(t => t.TUniverso)
                .Where(p => p.IdUniverso == id && p.ejemplo == false);
            return(View());
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TUniverso tUniverso = db.TUniverso.Find(id);

            db.TProblema.RemoveRange(tUniverso.TProblema);
            db.TParametro.RemoveRange(tUniverso.TParametro);

            db.TUniverso.Remove(tUniverso);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "IdUniverso,NombUniverso,CantNiveles")] TUniverso tUniverso)
        {
            if (ModelState.IsValid)
            {
                var u = db.TUniverso.Where(p => p.NombUniverso == tUniverso.NombUniverso).ToList();
                if (u.Count > 0)
                {
                    ViewBag.error = "Ya existe un Universo con ese Nombre";
                    return(View(tUniverso));
                }
                db.TUniverso.Add(tUniverso);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tUniverso));
        }
예제 #4
0
        // GET: TUniversoes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TUniverso tUniverso = db.TUniverso.Find(id);

            if (tUniverso == null)
            {
                return(HttpNotFound());
            }
            return(View(tUniverso));
        }
예제 #5
0
        //Complejidad
        private void SetComplexity(TProblema t, ICollection <TProblemaParametro> p)
        {
            p = new List <TProblemaParametro>(p.OrderBy(a => a.Valor));

            if (p.Count == 1)
            {
                t.ComplejidadId = 1;
            }
            else
            {
                List <double> valores = new List <double>();
                foreach (var val in p)
                {
                    if (val.Valor != null)
                    {
                        valores.Add((double)val.Valor);
                    }
                }
                double     inc        = valores[0];
                double     final      = valores[valores.Count - 1];
                List <int> resultados = new List <int>();

                int       cont = 1;
                TUniverso u    = db.TUniverso.Find(t.IdUniverso);
                for (int i = 0; i < u.CantNiveles; i++)
                {
                    object[] intervalo = Intervals(cont, final, inc);//obtener el nivel donde esta ubicado este valor.
                    foreach (var par in p)
                    {
                        if (Ubicar(intervalo, par)) //saber si en que posicion del intervalo esta el parametro
                        {
                            resultados.Add(cont);   // Agregarlo a la lista de resultados
                        }
                    }
                    cont++;
                }
                resultados = new List <int>(resultados.OrderByDescending(i => i));
                List <object[]> fin = new List <object[]>();
                for (int i = 0; i < resultados.Count; i++)
                {
                    List <int> repeticiones = new List <int>();
                    int        n            = resultados[0];
                    repeticiones.Add(n);
                    for (int j = 1; j < resultados.Count; j++)
                    {
                        if (n == resultados[j])
                        {
                            repeticiones.Add(n);
                            resultados.RemoveAt(j);
                            j--;
                        }
                    }
                    resultados.RemoveAt(0);
                    i--;
                    object[] o = new object[2];
                    o[0] = n;
                    o[1] = repeticiones.Count;
                    fin.Add(o);
                }//Obtener repeticiones del parametro en un intervalo
                fin = new List <object[]>(fin.OrderByDescending(k => k[1]));
                if (Iguales(fin))//Si las cantidades son iguales
                {
                    //Teoria de Desicion Laplace
                    t.ComplejidadId = int.Parse(fin[fin.Count - 1][0].ToString());
                }
                else
                {
                    if (fin.Count == 2)
                    {
                        t.ComplejidadId = int.Parse(fin[1][0].ToString());
                    }
                    else
                    {
                        t.ComplejidadId = int.Parse(fin[0][0].ToString());
                    }
                }
            }
        }