Esempio n. 1
0
 public RoleFunction AssignRole(FunctionItem function, Role role)
 {
     if (function == null)
         throw new ArgumentNullException("function");
     if (role == null)
         throw new ArgumentNullException("role");
     var roleFunction = _roleFunctionRepository.GetFiltered(p => p.FunctionItemId == function.Id)
         .FirstOrDefault();
     if (roleFunction == null)
     {
         roleFunction = new RoleFunction(function.Id, role.Id);
         _roleFunctionRepository.Add(roleFunction);
     }
     else
     {
         //roleFunction.SetRoleId(role.Id);
         _roleFunctionRepository.Modify(roleFunction);
     }
     return roleFunction;
 }
Esempio n. 2
0
 /// <summary>
 ///     插入角色功能
 /// </summary>
 /// <param name="role">角色</param>
 /// <param name="roleFunctionDto">角色功能DTO</param>
 private void InsertRoleFunction(Role role, RoleFunctionDTO roleFunctionDto)
 {
     var persist = _roleFunctionRepository.Get(roleFunctionDto.Id);
     if (persist != null) return;
     var roleFunction = new RoleFunction(role.Id, roleFunctionDto.FunctionItemId);
     _roleFunctionRepository.Add(roleFunction);
 }