Method AssignAsync
- Namespace
- MailFathom.Infrastructure.Persistence.Users
- Assembly
- MailFathom.Infrastructure.dll
AssignAsync(Guid, UserId, long, CancellationToken)
Assigns an account to one more user, where the two belong to the same organization or both to none and the account is assigned to fewer users than MaximumUsersAssignedIn(Guid?) admits where it belongs.
Task<MailAccountWrite> AssignAsync(Guid accountId, UserId user, long expectedUserVersion, CancellationToken cancellationToken)
Parameters
accountIdGuidThe account.
userUserIdThe user it is assigned to.
expectedUserVersionlongThe version of that user's record the assignment was judged against.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<MailAccountWrite>
What the write did, carrying both organizations where they differ.
Remarks
The account's row is held for the rest of the transaction before its users are counted, so two assignments of one account count one after the other and neither takes it past the bound. For an account in no organization that bound is one, so of two assignments landing at once the second is answered SharedOnlyInOrganization.