Esempio n. 1
0
 public OrganizationRole AssignRole(Organization organization, Role role)
 {
     if (organization == null)
         throw new ArgumentNullException("organization");
     if (role == null)
         throw new ArgumentNullException("role");
     var organizationRole = _organizationRoleRepository.GetFiltered(p => p.OrganizationId == organization.Id)
         .FirstOrDefault();
     if (organizationRole == null)
     {
         organizationRole = new OrganizationRole(organization.Id, role.Id);
         _organizationRoleRepository.Add(organizationRole);
     }
     else
     {
         organizationRole.SetRoleId(role.Id);
         _organizationRoleRepository.Modify(organizationRole);
     }
     return organizationRole;
 }
Esempio n. 2
0
        /// <summary>
        /// 新增OrganizationRole
        /// </summary>
        /// <returns></returns>
        public OrganizationRole AddNewOrganizationRole()
        {
            var organizationRole = new OrganizationRole
            {
                OrganizationId = Id,
            };

            organizationRole.GenerateNewIdentity();
            OrganizationRoles.Add(organizationRole);

            return organizationRole;
        }
Esempio n. 3
0
 /// <summary>
 /// 设置OrganizationRole
 /// </summary>
 /// <param name="organizationRole">组织机构角色</param>
 /// <param name="organizationId">组织机构</param>
 /// <param name="roleId">角色</param>
 public static void SetOrganizationRole(OrganizationRole organizationRole, int organizationId, int roleId)
 {
     organizationRole.OrganizationId = organizationId;
     organizationRole.RoleId = roleId;
 }
Esempio n. 4
0
 /// <summary>
 ///     更新OrganizationRole
 /// </summary>
 /// <param name="organizationRoleDto">OrganizationRoleDTO</param>
 /// <param name="organizationRole">OrganizationRole</param>
 private void UpdateOrganizationRole(OrganizationRoleDTO organizationRoleDto, OrganizationRole organizationRole)
 {
     // 更新OrganizationRole
     OrganizationFactory.SetOrganizationRole(organizationRole, organizationRoleDto.OrganizationId,
         organizationRoleDto.RoleId);
 }