Example #1
0
 public ActionResult Delete(Role role)
 {
     //Role role = db.Roles.Find(id);
     //db.Roles.Remove(role);
     //db.SaveChanges();
     rm.Delete(role);
     return RedirectToAction("Index");
 }
Example #2
0
        public ActionResult Create(Role role)
        {
            if (ModelState.IsValid)
            {
                role.RoleId = Guid.NewGuid();
                //db.Roles.Add(role);
                //db.SaveChanges();
                rm.Delete(role);
                return RedirectToAction("Index");
            }

            return View(role);
        }
Example #3
0
        public Models.Role Find(Guid roleId, bool loadOperations=false)
        {
            //db.Roles.Select(c => new { A = c.RoleId,B=c.Name });
            if (loadOperations)
            {
                return db.Roles.Include(c => c.Operations).SingleOrDefault(c => c.RoleId == roleId);
            }
            else
            {
                Role r = new Role();

                return db.Roles.Find(roleId);
            }
        }
Example #4
0
 public ActionResult Edit(Role role)
 {
     if (ModelState.IsValid)
     {
         //db.Entry(role).State = EntityState.Modified;
         //db.SaveChanges();
         rm.Edit(role);
         return RedirectToAction("Index");
     }
     return View(role);
 }
Example #5
0
 public void RemoveOperations(Role role)
 {
     //role.Operations.Remove(
 }
Example #6
0
 public void AddOperation(Role role, string operationId)
 {
     Operation op = db.Operations.Find(Guid.Parse(operationId));
     role.Operations.Add(op);
 }
Example #7
0
 public void AddMenu(Role role, string menuId)
 {
     Menu op = db.Menus.Find(Guid.Parse(menuId));
     role.Menus.Add(op);
 }