예제 #1
0
 public void AssignRole(RoleUser roleUser, Role role)
 {
     roleUser.Roles.Add(role);
 }
예제 #2
0
 public void AssignPrivilegeToUser(RoleUser roleUser, Privilege privilege)
 {
     roleUser.Privileges.Add(privilege);
 }
예제 #3
0
 public void AssignPrivilegeToUser(RoleUser roleUser, Privilege privilege)
 {
     roleUser.Privileges.Add(privilege);
 }
예제 #4
0
 public void AssignRole(RoleUser roleUser, Role role)
 {
     roleUser.Roles.Add(role);
 }
예제 #5
0
 private void InitUnitPermissions(Unit unit, User admin)
 {
     var privilegeRepository = new PrivilegeRepository();
     var privileges = privilegeRepository.GetAllPrivileges();
     var roleRepository = new RoleRepository();
     var roles = roleRepository.GetAllRoleByUnitId(unit.Id);
     var role = roles.FirstOrDefault(r => r.Code == "SuperAdmin");
     if (role == null)
     {
         role = new Role();
         role.Name = "超级管理员";
         role.Code = "SuperAdmin";
         role.UnitId = unit.Id;
         privileges.ToList().ForEach(privilege => role.Privileges.Add(privilege));
         roleRepository.Save(role);
     }
     var roleUserRepository = new RoleUserRepository();
     var roleUser = roleUserRepository.GetRoleUserByUserId(admin.Id);
     if (roleUser == null)
     {
         roleUser = new RoleUser();
         roleUser.UserId = admin.Id;
         roleUser.Roles.Add(role);
         roleUserRepository.Save(roleUser);
     }
 }