| | | 1 | | using Elsa.Common.Multitenancy; |
| | | 2 | | using Elsa.Identity.Entities; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Identity.Models; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Represents a role filter. |
| | | 8 | | /// </summary> |
| | | 9 | | public class RoleFilter |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Gets or sets the role ID to filter for. |
| | | 13 | | /// </summary> |
| | 221 | 14 | | public string? Id { get; set; } |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Gets or sets the role IDs to filter for. |
| | | 18 | | /// </summary> |
| | 88 | 19 | | public ICollection<string>? Ids { get; set; } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Gets or sets the tenant to filter for. The tenant-agnostic sentinel is always included, matching |
| | | 23 | | /// the Entity Framework query filter, so a shared platform role remains visible from every tenant. |
| | | 24 | | /// Legacy records without a tenant remain visible to the default tenant for backwards compatibility. |
| | | 25 | | /// </summary> |
| | 91 | 26 | | public string? TenantId { get; set; } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Applies the filter to the specified queryable. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="queryable">The queryable.</param> |
| | | 32 | | /// <returns>The filtered queryable.</returns> |
| | | 33 | | public IQueryable<Role> Apply(IQueryable<Role> queryable) |
| | | 34 | | { |
| | 83 | 35 | | var filter = this; |
| | 156 | 36 | | if (filter.Id != null) queryable = queryable.Where(x => x.Id == filter.Id); |
| | 86 | 37 | | if (filter.Ids != null) queryable = queryable.Where(x => filter.Ids.Contains(x.Id)); |
| | 83 | 38 | | if (filter.TenantId != null) |
| | 4 | 39 | | queryable = queryable.Where(x => x.TenantId == filter.TenantId || x.TenantId == Tenant.AgnosticTenantId || ( |
| | | 40 | | |
| | 83 | 41 | | return queryable; |
| | | 42 | | } |
| | | 43 | | } |