Interface IContactStore
- Namespace
- MailFathom.Application.Contacts
- Assembly
- MailFathom.Application.dll
Keeps the contact books, and erases a record of one completely when somebody asks.
public interface IContactStore
Remarks
The two staging operations write through the caller's session and commit nothing, as ADR 0001 requires of a write port: the caller decides the transaction, and the retry policy above it decides what a lost race means. Which addresses one contact may hold is the domain's rule; which contact may hold an address is this store's, enforced by a unique constraint rather than by a check before the insert, because two callers claiming one address pass any such check.
Every write names the book it acts on and the store applies it rather than trusting the record it was handed: an identifier that names a contact of another book is a book that holds no such contact, so a write cannot cross from one book into another by naming a row it read elsewhere. Which contact may hold an address is therefore a rule within a book rather than across the table, and the unique constraint underneath leads with the book to say so.
Erasure is the one act stated over a whole scope rather than over one book, because a person asking to be taken out is asking about everything the user in front of them can see: the record may be one they wrote down or one a mailbox of theirs collected, and answering "which book was that in" is not the data subject's problem. Erasing a collected record takes it out of the account's book, which is to say for every user assigned that account — the record was always one record rather than a copy each.
Erasure joins a session for the same reason the other two do, and for one of its own: what it reports having removed and what it removed are read in one transaction, so the count is a fact rather than a number that was true a moment earlier. The rows derived from a contact go with it through the schema's own cascade rather than through a second statement somebody remembers to write. It is the data-subject erasure path, so it removes rather than marks.
Methods
- AddAsync(IPersistenceSession, ContactBookHolder, Contact, CancellationToken)
Stages a contact the book does not yet hold.
- EraseAsync(IPersistenceSession, ContactBookScope, ContactId, CancellationToken)
Erases one contact and everything derived from it, from whichever book of the scope holds it.
- EraseCollectedAsync(IPersistenceSession, MailAccountId, CancellationToken)
Erases the whole of one mail account's collected book, and everything derived from it.
- ReplaceAsync(IPersistenceSession, ContactBookHolder, Contact, CancellationToken)
Stages the held record being replaced by the one supplied, address rows included.