Esempio n. 1
0
 public ActionResult Edit([Bind(Include = "ID_LEVEL1,NAME_LEVEL1")] LEVEL1 lEVEL1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lEVEL1).State = EntityState.Modified;
         var list = db.LEVEL4.Where(c => c.LEVEL3.LEVEL2.LEVEL1.ID_LEVEL1 == lEVEL1.ID_LEVEL1);
         foreach (var item in list)
         {
             LEVEL4 level4aux = db.LEVEL4.Find(item.ID_LEVEL4);
             LEVEL2 level2aux = db.LEVEL2.Find(item.LEVEL3.ID_LEVEL2);
             LEVEL1 level1aux = db.LEVEL1.Find(level2aux.ID_LEVEL1);
             level4aux.TAG = level2aux.LEVEL1.NAME_LEVEL1 + " " +
                             level2aux.NAME_LEVEL2 + " " +
                             level4aux.LEVEL3.NAME_LEVEL3 + " " +
                             level4aux.NAME_LEVEL4;
             db.Entry(level4aux).State = EntityState.Modified;
         }
         db.SaveChanges();
         if (!Ordenador.GenerarMenuDinamico())
         {
             return(View("ErrorPage"));
         }
         return(RedirectToAction("Index"));
     }
     return(View(lEVEL1));
 }
Esempio n. 2
0
        public ActionResult DeleteAll(decimal id)
        {
            LEVEL1        lEVEL1    = db.LEVEL1.Find(id);
            var           lEVEL2    = db.LEVEL2.Where(c => c.LEVEL1.ID_LEVEL1 == lEVEL1.ID_LEVEL1);
            List <LEVEL2> recorrido = lEVEL2.ToList();

            foreach (var item in recorrido)
            {
                var           lEVEL3          = db.LEVEL3.Where(c => c.LEVEL2.ID_LEVEL2 == item.ID_LEVEL2);
                List <LEVEL3> recorridoLevel3 = lEVEL3.ToList();
                foreach (var itemLevel3 in recorridoLevel3)
                {
                    var           lEVEL4          = db.LEVEL4.Where(c => c.LEVEL3.ID_LEVEL3 == itemLevel3.ID_LEVEL3);
                    List <LEVEL4> recorridoLevel4 = lEVEL4.ToList();
                    foreach (var itemLevel4 in recorridoLevel4)
                    {
                        db.LEVEL4.Remove(itemLevel4);
                    }
                    db.SaveChanges();
                    db.LEVEL3.Remove(itemLevel3);
                }
                db.SaveChanges();
                db.LEVEL2.Remove(item);
            }
            db.SaveChanges();
            db.LEVEL1.Remove(lEVEL1);
            db.SaveChanges();
            Ordenador.OrdenarLevel();
            if (!Ordenador.GenerarMenuDinamico())
            {
                return(View("ErrorPage"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        //public async Task<ActionResult> DeleteConfirmed(decimal id)
        public ActionResult DeleteConfirmed(decimal id)
        {
            LEVEL4 lEVEL4 = db.LEVEL4.Find(id);

            db.LEVEL4.Remove(lEVEL4);
            db.SaveChanges();
            if (!Ordenador.GenerarMenuDinamico())
            {
                return(View("ErrorPage"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "ID_LEVEL1,NAME_LEVEL1")] LEVEL1 lEVEL1)
        {
            lEVEL1.ID_LEVEL1 = db.LEVEL1.Count() + 1;
            if (ModelState.IsValid)
            {
                db.LEVEL1.Add(lEVEL1);
                db.SaveChanges();
                if (!Ordenador.GenerarMenuDinamico())
                {
                    return(View("ErrorPage"));
                }
                return(RedirectToAction("Index"));
            }

            return(View(lEVEL1));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "ID_LEVEL2,ID_LEVEL1,NAME_LEVEL2")] LEVEL2 lEVEL2)
        {
            lEVEL2.ID_LEVEL2 = db.LEVEL2.Count() + 1;
            if (ModelState.IsValid)
            {
                db.LEVEL2.Add(lEVEL2);
                db.SaveChanges();
                if (!Ordenador.GenerarMenuDinamico())
                {
                    return(View("ErrorPage"));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_LEVEL1 = new SelectList(db.LEVEL1, "ID_LEVEL1", "NAME_LEVEL1", lEVEL2.ID_LEVEL1);
            return(View(lEVEL2));
        }
Esempio n. 6
0
        public ActionResult DeleteAll(decimal id)
        {
            LEVEL3        lEVEL3    = db.LEVEL3.Find(id);
            var           lEVEL4    = db.LEVEL4.Where(c => c.LEVEL3.ID_LEVEL3 == lEVEL3.ID_LEVEL3);
            List <LEVEL4> recorrido = lEVEL4.ToList();

            foreach (var item in recorrido)
            {
                db.LEVEL4.Remove(item);
            }
            db.SaveChanges();
            db.LEVEL3.Remove(lEVEL3);
            db.SaveChanges();
            if (!Ordenador.GenerarMenuDinamico())
            {
                return(View("ErrorPage"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        //public async Task<ActionResult> Edit([Bind(Include = "ID_LEVEL4,ID_LEVEL3,NAME_LEVEL4,VINCULOPOWERBI,TAG")] LEVEL4 lEVEL4)
        public ActionResult Edit([Bind(Include = "ID_LEVEL4,ID_LEVEL3,NAME_LEVEL4,VINCULOPOWERBI,TAG")] LEVEL4 lEVEL4)
        {
            if (ModelState.IsValid)
            {
                LEVEL3 level3aux = db.LEVEL3.Find(lEVEL4.ID_LEVEL3);
                lEVEL4.TAG = level3aux.LEVEL2.LEVEL1.NAME_LEVEL1 + " " +
                             level3aux.LEVEL2.NAME_LEVEL2 + " " +
                             level3aux.NAME_LEVEL3 + " " +
                             lEVEL4.NAME_LEVEL4;
                db.Entry(lEVEL4).State = EntityState.Modified;
                db.SaveChanges();
                if (!Ordenador.GenerarMenuDinamico())
                {
                    return(View("ErrorPage"));
                }

                return(RedirectToAction("Index"));
            }
            ViewBag.ID_LEVEL3 = new SelectList(db.LEVEL3, "ID_LEVEL3", "NAME_LEVEL3", lEVEL4.ID_LEVEL3);
            return(View(lEVEL4));
        }
Esempio n. 8
0
        public ActionResult DeleteConfirmed(decimal id)
        {
            LEVEL2 lEVEL2 = db.LEVEL2.Find(id);

            db.LEVEL2.Remove(lEVEL2);
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                var lEVEL3 = db.LEVEL3.Include(l => l.LEVEL2).Where(c => c.LEVEL2.ID_LEVEL2 == lEVEL2.ID_LEVEL2);
                //return View(    lEVEL4.ToListAsync());
                ViewBag.Level2 = lEVEL2;
                return(View("Level3PorBorrar", lEVEL3.ToList()));
            }
            if (!Ordenador.GenerarMenuDinamico())
            {
                return(View("ErrorPage"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 9
0
        public ActionResult DeleteConfirmed(decimal id)
        {
            LEVEL1 lEVEL1 = db.LEVEL1.Find(id);

            db.LEVEL1.Remove(lEVEL1);
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                var lEVEL2 = db.LEVEL2.Include(l => l.LEVEL1).Where(c => c.LEVEL1.ID_LEVEL1 == lEVEL1.ID_LEVEL1);
                //return View(    lEVEL4.ToListAsync());
                ViewBag.Level1 = lEVEL1;
                return(View("Level2PorBorrar", lEVEL2.ToList()));
            }
            //db.Database.ExecuteSqlCommand("BEGIN LLENAR_MENU; END; ");
            Ordenador.OrdenarLevel();
            if (!Ordenador.GenerarMenuDinamico())
            {
                return(View("ErrorPage"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
        //public async Task<ActionResult> Create([Bind(Include = "ID_LEVEL4,ID_LEVEL3,NAME_LEVEL4,VINCULOPOWERBI,TAG")] LEVEL4 lEVEL4)
        public ActionResult Create([Bind(Include = "ID_LEVEL4,ID_LEVEL3,NAME_LEVEL4,VINCULOPOWERBI,TAG")] LEVEL4 lEVEL4)
        {
            //lEVEL4.ID_LEVEL4 = db.LEVEL4.Max(c => c.ID_LEVEL4) + 1;
            lEVEL4.ID_LEVEL4 = db.LEVEL4.Count() + 1;
            LEVEL3 level3aux = db.LEVEL3.Find(lEVEL4.ID_LEVEL3);

            lEVEL4.TAG = level3aux.LEVEL2.LEVEL1.NAME_LEVEL1 + " " +
                         level3aux.LEVEL2.NAME_LEVEL2 + " " +
                         level3aux.NAME_LEVEL3 + " " +
                         lEVEL4.NAME_LEVEL4;
            if (ModelState.IsValid)
            {
                db.LEVEL4.Add(lEVEL4);
                if (!Ordenador.GenerarMenuDinamico())
                {
                    return(View("ErrorPage"));
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_LEVEL3 = new SelectList(db.LEVEL3, "ID_LEVEL3", "NAME_LEVEL3", lEVEL4.ID_LEVEL3);
            return(View(lEVEL4));
        }