public void EditRoleMap(RoleEditModel model) { _rolePermissionsMapService.DeleteByRoleId(model.Id); var rolePermissionsMap = new List <RolePermissionsMap>(); var permissions = _permissionsService.Fetch(); model.PermissionIds.ForEach(m => { var permission = permissions.FirstOrDefault(n => n.Id == int.Parse(m)); rolePermissionsMap = GetRolePermissionsMap(rolePermissionsMap, model.PermissionIds, permissions, permission.ParentId); rolePermissionsMap.Add(new RolePermissionsMap { PermissionId = int.Parse(m), RoleId = model.Id, ParentId = permission.ParentId }); }); rolePermissionsMap.ForEach(m => { m.RoleId = model.Id; _rolePermissionsMapService.Add(m); }); _unitOfWork.Commit(); }
public ActionResult Delete(int id) { _rolePermissionsMapService.DeleteByRoleId(id); _roleService.Delete(id); return(RedirectToAction("Index", "Home")); }