Esempio n. 1
0
        public ActionResult Create(role role)
        {
            if (ModelState.IsValid)
            {
                db.roles.Add(role);
                var rolemodules = db.rolemodules.ToList();
                foreach (rolemodule rm in rolemodules)
                {
                    rolemodulepermission rolemodulepermission = new rolemodulepermission();
                    rolemodulepermission.roleid       = role.id;
                    rolemodulepermission.rolemoduleid = rm.id;
                    rolemodulepermission.permission   = false;
                    db.rolemodulepermissions.Add(rolemodulepermission);
                }
                var roleModuleActions = db.rolemoduleactions.ToList();
                foreach (rolemoduleaction ra in roleModuleActions)
                {
                    rolemoduleactionpermission rolemoduleactionpermission = new rolemoduleactionpermission();
                    rolemoduleactionpermission.roleid             = role.id;
                    rolemoduleactionpermission.rolemoduleactionid = ra.id;
                    rolemoduleactionpermission.permission         = false;
                    db.rolemoduleactionpermissions.Add(rolemoduleactionpermission);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
        public ActionResult Create(rolemoduleaction rolemoduleaction)
        {
            if (ModelState.IsValid)
            {
                db.rolemoduleactions.Add(rolemoduleaction);
                var roles = db.roles.ToList();
                foreach (role r in roles)
                {
                    rolemoduleactionpermission rolemoduleactionpermission = new rolemoduleactionpermission();
                    rolemoduleactionpermission.roleid             = r.id;
                    rolemoduleactionpermission.rolemoduleactionid = rolemoduleaction.id;
                    if (r.id == 1)
                    {
                        rolemoduleactionpermission.permission = true;
                    }
                    else
                    {
                        rolemoduleactionpermission.permission = false;
                    }
                    db.rolemoduleactionpermissions.Add(rolemoduleactionpermission);
                }
                db.SaveChanges();
                return(RedirectToAction("Create"));
                //  return RedirectToAction("Index");
            }

            ViewBag.rolemoduleid = new SelectList(db.rolemodules, "id", "name", rolemoduleaction.rolemoduleid);
            return(View(rolemoduleaction));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            rolemoduleactionpermission rolemoduleactionpermission = db.rolemoduleactionpermissions.Find(id);

            db.rolemoduleactionpermissions.Remove(rolemoduleactionpermission);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(int id)
        {
            rolemoduleactionpermission rolemoduleactionpermission = db.rolemoduleactionpermissions.Find(id);

            ViewBag.roleid             = new SelectList(db.roles, "id", "roleName", rolemoduleactionpermission.roleid);
            ViewBag.rolemoduleid       = new SelectList(db.rolemodules, "id", "name", rolemoduleactionpermission.rolemoduleaction.rolemoduleid);
            ViewBag.rolemoduleactionid = new SelectList(db.rolemoduleactions, "id", "name", rolemoduleactionpermission.rolemoduleactionid);
            return(View(rolemoduleactionpermission));
        }
 public ActionResult Edit(rolemoduleactionpermission rolemoduleactionpermission)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rolemoduleactionpermission).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.roleid             = new SelectList(db.roles, "id", "roleName", rolemoduleactionpermission.roleid);
     ViewBag.rolemoduleactionid = new SelectList(db.rolemoduleactions, "id", "name", rolemoduleactionpermission.rolemoduleactionid);
     return(View(rolemoduleactionpermission));
 }
 public ActionResult DeleteFromGrid(int id)
 {
     try
     {
         rolemoduleactionpermission rolemoduleactionpermission = db.rolemoduleactionpermissions.Find(id);
         db.rolemoduleactionpermissions.Remove(rolemoduleactionpermission);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted succesfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { success = false, message = "Not deleted" }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Create(rolemoduleactionpermission rolemoduleactionpermission)
        {
            if (ModelState.IsValid)
            {
                db.rolemoduleactionpermissions.Add(rolemoduleactionpermission);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.roleid             = new SelectList(db.roles, "id", "roleName", rolemoduleactionpermission.roleid);
            ViewBag.rolemoduleid       = new SelectList(db.rolemodules, "id", "name", rolemoduleactionpermission.rolemoduleaction.rolemoduleid);
            ViewBag.rolemoduleactionid = new SelectList(db.rolemoduleactions, "id", "name", rolemoduleactionpermission.rolemoduleactionid);
            return(View(rolemoduleactionpermission));
        }
 public ActionResult gridAddOrUpdate(rolemoduleactionpermission rolemoduleactionpermission)
 {
     try
     {
         if (rolemoduleactionpermission.id.CompareTo(0) > 0)
         {
             db.Entry(rolemoduleactionpermission).State = EntityState.Modified;
         }
         else
         {
             db.rolemoduleactionpermissions.Add(rolemoduleactionpermission);
         }
         db.SaveChanges();
     }
     catch (Exception e)
     {
         return(Json(new { success = false, message = "Record not added" }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { success = true, message = "Record Added" }, JsonRequestBehavior.AllowGet));
 }
        public ViewResult Details(int id)
        {
            rolemoduleactionpermission rolemoduleactionpermission = db.rolemoduleactionpermissions.Find(id);

            return(View(rolemoduleactionpermission));
        }
        public ActionResult Delete(int id)
        {
            rolemoduleactionpermission rolemoduleactionpermission = db.rolemoduleactionpermissions.Find(id);

            return(View(rolemoduleactionpermission));
        }