OP-007: Insert, update, or delete a stored preference set¶
SavePreferences is invoked over the PreferenceService route on SAIF.Services.WCF.Services.PreferenceService; this page documents the process end to end, from route dispatch to the message the caller receives.
Field
Value
Operation ID
OP-007
Trigger
Caller invokes SavePreferences over the PreferenceService route.
Enforce.ArgumentNotNullOrEmpty(currentUser, "currentUser") runs before any database work (BR-WCF-007).
On failure: ArgumentNullException, logged and surfaced as a generic SOAP fault.
unitOfWork.Begin() opens the transaction boundary that covers the remaining steps.
Lower-case currentUser into the audit field and re-run QueryPrefs to locate any existing record (BR-WCF-005, BR-WCF-011).
No existing record and a non-empty preferences dictionary: AddPreference builds a Preference (storing a blank page name as null) and calls repository.Add (BR-WCF-008).
Existing record and an empty preferences dictionary: DeletePreference calls repository.Delete (BR-WCF-009).
Existing record and a non-empty dictionary: UpdatePreference repopulates the tracked entity in place (BR-WCF-010); PopulatePreference serializes the dictionary to JSON and stamps UpdateDate = DateTime.Now and UpdateUser = currentUser (BR-WCF-011).
unitOfWork.Commit().
On failure before commit: logged by the installed error handler, surfaced as a generic SOAP fault, and the transaction is rolled back when Dispose runs.
The following diagram visualizes this process's control flow.
flowchart TD
A["Validate currentUser is present"]
B["Begin transaction"]
C["Normalize currentUser and<br>locate existing record"]
C1{"Existing record<br>and preferences dictionary"}
D["Insert new preference record"]
E["Delete existing preference record"]
F["Update existing preference record"]
G["unitOfWork.Commit()."]
A --> B
B --> C
C --> C1
C1 -->|"No existing record, non-empty"| D
C1 -->|"Existing record, empty"| E
C1 -->|"Existing record, non-empty"| F
D --> G
E --> G
F --> G
Note: Statements marked with * were inferred from code structure, naming
conventions, or contextual evidence where direct confirmation was not available
in source artifacts. Statements marked with ** could not be confirmed; treat
as unknown until verified.