Example #1
0
        public ActionResult NuevoElemento(ViewElement Model)
        {
            Security sc = new Security();
            //http://mvc3only.blogspot.com/2012/04/aspnet-mvc3-ajax-form-submission-simple.html
            //http://www.deliveron.com/blog/post/creating-a-cascading-dropdown-in-aspnet-mvc-3-and-jquery.aspx
            //http://forums.asp.net/t/1909055.aspx
            Element nuevo = new Element();
            nuevo.Name = Model.Nombre;
            nuevo.Resumen = Model.Resumen;
            nuevo.UsuarioCreacion = "system"; ;//User.Identity.Name;
            nuevo.UsuarioModificacion = "system";
            nuevo.FechaCreacion = DateTime.Now;
            nuevo.FechaModificacion = DateTime.Now;

            if (Model.Aplicacion == 0) //Se ingresa una aplicacion
            {
                nuevo.RelativeId = sc.Elements.Where(n => n.Name == "Aplicacion").FirstOrDefault().Id;
            }else
                if (Model.Area == 0)// se ingresa un area
                {
                    nuevo.RelativeId = Model.Aplicacion;
                }
                else
                    if (Model.Controller == 0)//se ingresa un controller
                    {
                        nuevo.RelativeId = Model.Area;
                    }
                    else//se ingresa una vista
                    {
                        nuevo.RelativeId = Model.Controller;
                    }
            sc.Elements.Add(nuevo);
            sc.SaveChanges();
            //return Json("Ok", JsonRequestBehavior.AllowGet);
            return RedirectToAction("Nuevo");
        }
Example #2
0
 public ActionResult Nuevo()
 {
     Security sc = new Security();
     var model = new ViewElement();
     ViewBag.Aplicacion = new SelectList(new List<Element>() { new Element { Id = 0, Name = "" } }, "Id", "Name");
     ViewBag.Area = new SelectList(new List<Element>() { new Element { Id = 0, Name = "" } }, "Id", "Name");
     ViewBag.Controller = new SelectList(new List<Element>() { new Element { Id = 0, Name = "" } }, "Id", "Name");
     ViewBag.Vista = new SelectList(new List<Element>() { new Element { Id = 0, Name = "" } }, "Id", "Name");
     return View(model);
 }