Table of Contents

Interface ITeamRepository<TTeamEntity, TMember>

Namespace
Tharga.Team.MongoDB
Assembly
Tharga.Team.MongoDB.dll
public interface ITeamRepository<TTeamEntity, TMember> : IRepository where TTeamEntity : TeamEntityBase<TMember> where TMember : TeamMemberBase

Type Parameters

TTeamEntity
TMember

Methods

AddAsync(TTeamEntity)

Task AddAsync(TTeamEntity teamEntity)

Parameters

teamEntity TTeamEntity

Returns

Task

AddMemberAsync(string, TMember)

Task AddMemberAsync(string teamKey, TMember member)

Parameters

teamKey string
member TMember

Returns

Task

DeleteAsync(string)

Task DeleteAsync(string teamKey)

Parameters

teamKey string

Returns

Task

GetAllTeamsAsync()

Every team, regardless of membership — backs the cross-team discovery path authorized by Read.

IAsyncEnumerable<TTeamEntity> GetAllTeamsAsync()

Returns

IAsyncEnumerable<TTeamEntity>

Remarks

Declared with a default implementation so existing custom repositories keep compiling. The default throws rather than returning empty: a silently empty cross-team list is indistinguishable from a working feature that happens to have nothing to show, which hides the missing implementation.

GetAllTeamsIncludingDeletedAsync()

Every team including soft-deleted ones — the only read that sees them, for restore and purge surfaces.

IAsyncEnumerable<TTeamEntity> GetAllTeamsIncludingDeletedAsync()

Returns

IAsyncEnumerable<TTeamEntity>

Remarks

Deliberately a separate method rather than a flag on GetAllTeamsAsync(). A boolean parameter defaulting to "exclude" is one forgotten argument away from leaking deleted teams into an ordinary list; a distinct name has to be chosen on purpose.

GetAsync(string)

Task<TTeamEntity> GetAsync(string teamKey)

Parameters

teamKey string

Returns

Task<TTeamEntity>

GetByInviteKeyAsync(string)

The single live team holding an outstanding invitation with this code, or null when none or more than one does. Backed by the Members.Invitation.InviteKey index.

Task<TTeamEntity> GetByInviteKeyAsync(string inviteKey)

Parameters

inviteKey string

Returns

Task<TTeamEntity>

GetIncludingDeletedAsync(string)

Marks a team deleted, or clears the mark when deletedAt is null.

Task<TTeamEntity> GetIncludingDeletedAsync(string teamKey)

Parameters

teamKey string

Returns

Task<TTeamEntity>

Remarks

Declared with a default implementation so existing custom repositories keep compiling — and it throws rather than no-opping, because a soft delete that silently does nothing reports success while leaving the team live and readable, which is worse than refusing.

A repository that does not implement this makes its service report SupportsSoftDelete = false, so the throw is unreachable through the normal path: the delete resolves to the irreversible one the store already had.

GetTeamsByConsentAsync(string[])

IAsyncEnumerable<TTeamEntity> GetTeamsByConsentAsync(string[] roles)

Parameters

roles string[]

Returns

IAsyncEnumerable<TTeamEntity>

GetTeamsByUserAsync(string)

IAsyncEnumerable<TTeamEntity> GetTeamsByUserAsync(string userKey)

Parameters

userKey string

Returns

IAsyncEnumerable<TTeamEntity>

RemoveMemberAsync(string, string)

Task RemoveMemberAsync(string teamKey, string userKey)

Parameters

teamKey string
userKey string

Returns

Task

RemoveMemberFromAllTeamsAsync(string)

Removes the user's member entries from every team they appear in, regardless of membership state. Backs user deletion. Returns the number of teams the user was removed from.

Task<int> RemoveMemberFromAllTeamsAsync(string userKey)

Parameters

userKey string

Returns

Task<int>

Remarks

Declared with a default implementation so existing custom repositories keep compiling. The default throws rather than returning 0: a silent no-op on a deletion path would leave memberships behind while reporting success.

RenameAsync(string, string)

Task RenameAsync(string teamKey, string name)

Parameters

teamKey string
name string

Returns

Task

SetConsentAsync(string, string[], AccessLevel?)

Task SetConsentAsync(string teamKey, string[] consentedRoles, AccessLevel? accessLevel = null)

Parameters

teamKey string
consentedRoles string[]
accessLevel AccessLevel?

Returns

Task

SetCustomRolesAsync(string, IReadOnlyList<TenantRoleDefinition>)

Task SetCustomRolesAsync(string teamKey, IReadOnlyList<TenantRoleDefinition> customRoles)

Parameters

teamKey string
customRoles IReadOnlyList<TenantRoleDefinition>

Returns

Task

SetDeletedAsync(string, DateTime?, string)

Task SetDeletedAsync(string teamKey, DateTime? deletedAt, string deletedBy)

Parameters

teamKey string
deletedAt DateTime?
deletedBy string

Returns

Task

SetIconAsync(string, string)

Task SetIconAsync(string teamKey, string reference)

Parameters

teamKey string
reference string

Returns

Task

SetInvitationExpiryAsync(string, string, DateTime?)

Sets the expiry of the invitation matching inviteKey, leaving the code itself untouched so an already-mailed link keeps working.

Task SetInvitationExpiryAsync(string teamKey, string inviteKey, DateTime? expiresAt)

Parameters

teamKey string
inviteKey string
expiresAt DateTime?

Returns

Task

Remarks

A default interface method that no-ops, so a host with its own repository keeps compiling. The base service that calls it throws when it is not overridden, so the gap surfaces as an error at the point of use rather than as an extension that quietly did nothing.

SetInvitationResponseAsync(string, string, string, bool)

Task<ITeam> SetInvitationResponseAsync(string teamKey, string userKey, string inviteKey, bool accept)

Parameters

teamKey string
userKey string
inviteKey string
accept bool

Returns

Task<ITeam>

SetLastSeenAsync(string, string, DateTime)

Task SetLastSeenAsync(string teamKey, string userKey, DateTime utcNow)

Parameters

teamKey string
userKey string
utcNow DateTime

Returns

Task

SetMemberNameAsync(string, string, string)

Task SetMemberNameAsync(string teamKey, string userKey, string name)

Parameters

teamKey string
userKey string
name string

Returns

Task

SetMemberRoleAsync(string, string, AccessLevel)

Task SetMemberRoleAsync(string teamKey, string userKey, AccessLevel accessLevel)

Parameters

teamKey string
userKey string
accessLevel AccessLevel

Returns

Task

SetMemberScopeOverridesAsync(string, string, string[])

Task SetMemberScopeOverridesAsync(string teamKey, string userKey, string[] scopeOverrides)

Parameters

teamKey string
userKey string
scopeOverrides string[]

Returns

Task

SetMemberSuspendedAsync(string, string, DateTime?, string)

Task SetMemberSuspendedAsync(string teamKey, string userKey, DateTime? suspendedAt, string suspendedBy)

Parameters

teamKey string
userKey string
suspendedAt DateTime?
suspendedBy string

Returns

Task

SetMemberTenantRolesAsync(string, string, string[])

Task SetMemberTenantRolesAsync(string teamKey, string userKey, string[] tenantRoles)

Parameters

teamKey string
userKey string
tenantRoles string[]

Returns

Task