Table of Contents

Method CreateAsync

Namespace
MailFathom.Infrastructure.Persistence.Users
Assembly
MailFathom.Infrastructure.dll

CreateAsync(UserId, long, Func<GoverningSettingsPolicies, MailAccountCandidate?>, CancellationToken)

Creates an account in the organization of the user it is created for, and assigns it to them.

Task<MailAccountWrite> CreateAsync(UserId user, long expectedUserVersion, Func<GoverningSettingsPolicies, MailAccountCandidate?> compose, CancellationToken cancellationToken)

Parameters

user UserId

The user the account is created for.

expectedUserVersion long

The version of that user's record the account was judged against.

compose Func<GoverningSettingsPolicies, MailAccountCandidate>

Composes the account to create under the policies that will govern it, or answers null to create nothing. It is called inside the write's transaction, once per attempt, and performs no I/O of its own.

cancellationToken CancellationToken

Cancels the write.

Returns

Task<MailAccountWrite>

What the write did; an address another account holds leaves nothing written, and so does a composition that answered nothing.

Remarks

The policies are handed to the caller rather than read by it beforehand, for the reason a user's record is written the same way: what the account is judged by and what its columns hold have to be the policies in force when the write commits. They are read inside the transaction, under the lock a policy write excludes record writes with, and they are the policies of the organization the user stands in at that moment.

Exceptions

ArgumentNullException

Thrown when compose is null.