public ActionResult DeleteConfirmed(int id)
        {
            AdministracionRol administracionRol = db.AdministracionRols.Find(id);

            db.AdministracionRols.Remove(administracionRol);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "AdminRolID,Id_empleado,RolID")] AdministracionRol administracionRol)
 {
     if (ModelState.IsValid)
     {
         db.Entry(administracionRol).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id_empleado = new SelectList(db.Empleados, "Id_empleado", "Nombres", administracionRol.Id_empleado);
     ViewBag.RolID       = new SelectList(db.Roles, "RolID", "RolName", administracionRol.RolID);
     return(View(administracionRol));
 }
        // GET: AdministracionRols/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AdministracionRol administracionRol = db.AdministracionRols.Find(id);

            if (administracionRol == null)
            {
                return(HttpNotFound());
            }
            return(View(administracionRol));
        }
        // GET: AdministracionRols/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AdministracionRol administracionRol = db.AdministracionRols.Find(id);

            if (administracionRol == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id_empleado = new SelectList(db.Empleados, "Id_empleado", "Nombres", administracionRol.Id_empleado);
            ViewBag.RolID       = new SelectList(db.Roles, "RolID", "RolName", administracionRol.RolID);
            return(View(administracionRol));
        }
        public JsonResult Create([Bind(Include = "AdminRolID,Id_empleado,RolID")] AdministracionRol administracionRol)
        {
            var query = (from e in db.AdministracionRols
                         where (e.Id_empleado == administracionRol.Id_empleado)
                         select e).ToList();

            if (ModelState.IsValid)
            {
                if (query != null)
                {
                    ViewBag.Id_empleado = new SelectList(db.Empleados, "Id_empleado", "Nombres", administracionRol.Id_empleado);
                    ViewBag.RolID       = new SelectList(db.Roles, "RolID", "RolName", administracionRol.RolID);
                    return(Json(administracionRol, JsonRequestBehavior.AllowGet));
                }
                db.AdministracionRols.Add(administracionRol);
                db.SaveChanges();
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }

            ViewBag.Id_empleado = new SelectList(db.Empleados, "Id_empleado", "Nombres", administracionRol.Id_empleado);
            ViewBag.RolID       = new SelectList(db.Roles, "RolID", "RolName", administracionRol.RolID);
            return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
        }