Пример #1
0
        public ActionResult CrearAreaD(Nivel5 obj)
        {
            _context   = new BDContext();
            unitOfWork = new UnitOfWork(_context);
            List <Nivel4> Areas = new List <Nivel4>();

            foreach (var nusuario in unitOfWork.Nivel4.GetAll())
            {
                Areas.Add(nusuario);
            }
            ViewBag.Areas = Areas;
            return(View(obj));
        }
Пример #2
0
        public ActionResult ActionAsignarN5(int idUsuario, int idPermiso)
        {
            _context   = new BDContext();
            unitOfWork = new UnitOfWork(_context);
            Uppd       = unitOfWork.TipoDocumento.Get(idUsuario);
            Nivel5 permiso = unitOfWork.Nivel5.Get(idPermiso);

            Uppd.N5.Add(permiso);

            unitOfWork.Complete();

            return(RedirectToAction("AsignarRutasN5", new { idArea = idUsuario, perm = true, AQ = 1 }));
        }
Пример #3
0
        public ActionResult ActualizarAreaD(int idArea)
        {
            _context   = new BDContext();
            unitOfWork = new UnitOfWork(_context);
            List <Nivel4> Areas = new List <Nivel4>();

            foreach (var nusuario in unitOfWork.Nivel4.GetAll())
            {
                Areas.Add(nusuario);
            }
            ViewBag.Areas = Areas;
            Uppd          = unitOfWork.Nivel5.Get(idArea);
            return(View(Uppd));
        }
Пример #4
0
 public ActionResult ActionCrearAreaD(Nivel5 obj)
 {
     if (ModelState.IsValid)
     {
         _context   = new BDContext();
         unitOfWork = new UnitOfWork(_context);
         unitOfWork.Nivel5.Add(obj);
         unitOfWork.Complete();
         var    n4   = unitOfWork.Nivel4.Get(Int32.Parse(obj.nivel4));
         var    n3   = unitOfWork.Nivel3.Get(Int32.Parse(n4.nivel3));
         var    n2   = unitOfWork.Nivel2.Get(Int32.Parse(n3.nivel2));
         var    n1   = unitOfWork.Nivel1.Get(Int32.Parse(n2.nivel1));
         string path = Path.Combine(Server.MapPath("~/Gestad"), n1.nombreN, n2.nombreN, n3.nombreN, n4.nombreN, obj.nombreN);
         Directory.CreateDirectory(path);
         return(RedirectToAction("AreaDoc"));
     }
     else
     {
         return(RedirectToAction("CrearAreaD", obj));
     }
 }
Пример #5
0
        public ActionResult ActionActualizarAreaD(Nivel5 obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context   = new BDContext();
                    unitOfWork = new UnitOfWork(_context);
                    Uppd       = unitOfWork.Nivel5.Get(obj.idN);
                    unitOfWork.Nivel5.Update(Uppd);
                    Uppd.nombreN      = obj.nombreN;
                    Uppd.descripcionN = obj.descripcionN;

                    _context.Configuration.ValidateOnSaveEnabled = false;

                    unitOfWork.Complete();

                    var    n4   = unitOfWork.Nivel4.Get(Int32.Parse(obj.nivel4));
                    var    n3   = unitOfWork.Nivel3.Get(Int32.Parse(n4.nivel3));
                    var    n2   = unitOfWork.Nivel2.Get(Int32.Parse(n3.nivel2));
                    var    n1   = unitOfWork.Nivel1.Get(Int32.Parse(n2.nivel1));
                    string path = Path.Combine(Server.MapPath("~/Gestad"), n1.nombreN, n2.nombreN, n3.nombreN, n4.nombreN, obj.nombreN);
                    Directory.CreateDirectory(path);

                    return(RedirectToAction("AreaDoc"));
                }
                else
                {
                    return(View("ActualizarAreaD", obj));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Un error ha ocurrido '{0}'", ex);
                return(View("ActualizarAreaD"));
            }
        }
Пример #6
0
            private void GeneraSubMenus(Menu menu, List <ArbolAcceso> lstArboles, DataBaseModelContext db, string url)
            {
                try
                {
                    foreach (ArbolAcceso arbol in lstArboles)
                    {
                        if (arbol.Nivel1 != null)
                        {
                            if (menu.Menu1 == null)
                            {
                                menu.Menu1 = new List <Menu>();
                            }
                            Nivel1 n = db.Nivel1.SingleOrDefault(s => s.Id == arbol.Nivel1.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = arbol.Nivel2 != null ? string.Empty : url + arbol.Id
                                };
                                menu.Menu1.Add(menuNivel1);
                            }
                        }

                        if (arbol.Nivel2 != null)
                        {
                            if (menu.Menu1[0].Menu1 == null)
                            {
                                menu.Menu1[0].Menu1 = new List <Menu>();
                            }
                            Nivel2 n = db.Nivel2.SingleOrDefault(s => s.Id == arbol.Nivel2.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1[0].Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = arbol.Nivel3 != null ? string.Empty : url + arbol.Id
                                };
                                menu.Menu1[0].Menu1.Add(menuNivel1);
                            }
                        }

                        if (arbol.Nivel3 != null)
                        {
                            if (menu.Menu1[0].Menu1[0].Menu1 == null)
                            {
                                menu.Menu1[0].Menu1[0].Menu1 = new List <Menu>();
                            }
                            Nivel3 n = db.Nivel3.SingleOrDefault(s => s.Id == arbol.Nivel3.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1[0].Menu1[0].Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = arbol.Nivel4 != null ? string.Empty : url + arbol.Id
                                };
                                menu.Menu1[0].Menu1[0].Menu1.Add(menuNivel1);
                            }
                        }

                        if (arbol.Nivel4 != null)
                        {
                            if (menu.Menu1[0].Menu1[0].Menu1[0].Menu1 == null)
                            {
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1 = new List <Menu>();
                            }
                            Nivel4 n = db.Nivel4.SingleOrDefault(s => s.Id == arbol.Nivel4.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1[0].Menu1[0].Menu1[0].Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = arbol.Nivel5 != null ? string.Empty : url + arbol.Id
                                };
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1.Add(menuNivel1);
                            }
                        }

                        if (arbol.Nivel5 != null)
                        {
                            if (menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1 == null)
                            {
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1 = new List <Menu>();
                            }
                            Nivel5 n = db.Nivel5.SingleOrDefault(s => s.Id == arbol.Nivel5.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = arbol.Nivel6 != null ? string.Empty : url + arbol.Id
                                };
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1.Add(menuNivel1);
                            }
                        }

                        if (arbol.Nivel6 != null)
                        {
                            if (menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1 == null)
                            {
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1 = new List <Menu>();
                            }
                            Nivel6 n = db.Nivel6.SingleOrDefault(s => s.Id == arbol.Nivel6.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = arbol.Nivel7 != null ? string.Empty : url + arbol.Id
                                };
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1.Add(menuNivel1);
                            }
                        }
                        if (arbol.Nivel7 != null)
                        {
                            if (menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1 == null)
                            {
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1 = new List <Menu>();
                            }
                            Nivel5 n = db.Nivel5.SingleOrDefault(s => s.Id == arbol.Nivel7.Id);
                            if (n == null)
                            {
                                continue;
                            }
                            if (!menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1.Any(a => a.Id == n.Id))
                            {
                                Menu menuNivel1 = new Menu
                                {
                                    Descripcion = n.Descripcion,
                                    Id          = n.Id,
                                    Url         = url + arbol.Id
                                };
                                menu.Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1[0].Menu1.Add(menuNivel1);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }