public User SaveUser(User user, bool rolePermission, bool bRole) { int userId = manager.SaveUserBasicInfo(user.UserId, user.UserName, user.EmpName, user.Password, user.Mobile, user.EmployeeId, user.IsActive); user.UserId = userId; if (bRole) { manager.DeleteUserRoleByRoleId(userId); for (int i = 0; i < user.UserRoleCount; i++) { Role role = user[i, "notUse"]; manager.SaveUserRole(userId, role.RoleId); } } if (rolePermission) { for (int i = 0; i < user.UserRoleCount; i++) { Role userRolePermission = user[i, "notUser"]; manager.DeleteUserRolePermissionByUserRoleId(userId, userRolePermission.RoleId); } for (int i = 0; i < user.UserRolePermissionCount; i++) { UserRolePermission userRolePermission = user[i]; manager.SaveUserRolePermission(user.UserId, userRolePermission.Permission.PermissionId, userRolePermission.Role.RoleId); } } return(user); }
public bool HaveRolePermission(Role role, Permission permission) { UserRolePermission rolePermission = new UserRolePermission(); rolePermission.Permission = permission; rolePermission.Role = role; return(userRolePermissions.HavePermission(rolePermission)); }
public void AddPermission(Permission permission) { UserRolePermission rolePermission = new UserRolePermission(); rolePermission.Permission = permission; rolePermission.Role = Roles.DefaultRoles.AllPermission; AddRolePermission(rolePermission); }
public void AddRolePermission(UserRolePermission permission) { if (HavePermission(permission)) { return; } permissions.Add(permission); }
public void AddPermission(Permission permission, Role role) { if (role.Permissions.HavePermission(permission)) { UserRolePermission userRolePermission = new UserRolePermission(); userRolePermission.Permission = permission; userRolePermission.Role = role; //if (!userRoles.HaveRole(role)) //{ // userRoles.AddRole(role); //} userRolePermissions.AddRolePermission(userRolePermission); } }
public RolePermissionCollection GetPermissionsByRole(Role role) { RolePermissionCollection rolePermissions = new RolePermissionCollection(); for (int i = 0; i < permissions.Count; i++) { UserRolePermission rolePermission = permissions[i]; if (rolePermission.Role.Equals(role)) { rolePermissions.AddPermission(rolePermission.Permission); } } return(rolePermissions); }
public void DeleteByRole(Role role) { for (int i = 0; i < permissions.Count;) { UserRolePermission userRolePermission = permissions[i]; if (userRolePermission.Role.Equals(role)) { permissions.RemoveAt(i); } else { i++; } } }
public IList <Module> GetModules(Role role) { IList <Module> modules = new List <Module>(); for (int i = 0; i < userRolePermissions.Count; i++) { UserRolePermission rolePermission = userRolePermissions[i]; if (rolePermission.Role.Equals(role)) { if (!modules.Contains(rolePermission.Permission.Module)) { modules.Add(rolePermission.Permission.Module); } } } return(modules); }
public void AddPermissionByAddRole(Role role) { if (!userRoles.HaveRole(role)) { userRoles.AddRole(role); } for (int i = 0; i < role.Permissions.Count; i++) { Permission permission = role.Permissions[i]; if (!userRolePermissions.HavePermission(permission)) { UserRolePermission rolePermission = new UserRolePermission(); rolePermission.Role = role; rolePermission.Permission = permission; userRolePermissions.AddRolePermission(rolePermission); } } }
public bool HavePermission(UserRolePermission permission) { return(HavePermission(permission.Permission)); }