Method AmendAsync
- Namespace
- MailFathom.Application.Contacts
- Assembly
- MailFathom.Application.dll
AmendAsync(ContactBookScope, ContactAmendment, CancellationToken)
Amends a contact of the caller's own book to the record they state, if its origin admits that writer.
public Task<ContactWriteResult> AmendAsync(ContactBookScope scope, ContactAmendment amendment, CancellationToken cancellationToken)
Parameters
scopeContactBookScopeThe books the caller reads, whose own book the amendment may reach.
amendmentContactAmendmentThe record the contact is to have, and the origin the writer acts under.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task<ContactWriteResult>
The amended record, or the refusal naming what stopped it.
Remarks
It reads the whole scope and writes to the own book alone. Reading the whole of it is what lets a collected record be refused as one rather than as a record nobody holds: it is a mailbox's, several users may be reading it, and rewriting it in place would change what each of them sees — so the origin rule refuses the writer and PromoteAsync(ContactBookScope, ContactId, ContactOrigin, CancellationToken) is the act that makes a copy the user may amend. A contact outside the scope altogether is a contact this caller does not hold, and is answered as such — which is also what a collected record is to an administrator admitted below the deployment whose scope does not cover its mail account.
The grant is asked for before the book is read, so a caller who may not write cannot learn from the refusal whether the book holds the person they named.
Exceptions
- ArgumentNullException
Thrown when
scopeoramendmentis null.- ArgumentException
Thrown when the amendment does not form a contact the domain admits.
- PersistenceConcurrencyConflictException
Thrown when every allowed attempt lost the race.
- PrincipalNotAuthorizedException
Thrown when the write was reached by anything but a caller granted AdminOperate.