Skip to content

Build policy dropdown

When the policy dropdown is shown, the BolPolicyHeader view calls GetPolicyAssociationDropdown to produce the select list from the header associations.

Field Value
Operation ID OP-13
Trigger BolPolicyHeader view rendering
Inputs PolicyHeader with associations
Outputs SelectList of policy numbers and labels
Primary components HeaderExtensions.GetPolicyAssociationDropdown
Entry point src/BolMiddleware/Extensions/HeaderExtensions.cs

Steps

  1. Validate that the helper and header arguments are not null.
  2. Flatten the policies from every association into one list.
  3. Order the list by policy number descending (BR-BOLMIDDLEWARE-015).
  4. Move the policy that equals the header policy number to the first position.
  5. Add each policy to a dictionary keyed by policy number with the label <number> - <name>.
  6. If a policy number appears twice: Dictionary.Add throws an ArgumentException and the view fails.
  7. Return a SelectList over the dictionary. The view shows it only when the dropdown is allowed (BR-BOLMIDDLEWARE-012).

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Render dropdown]) --> S1[Flatten associations]
    S1 --> S2[Order by policy number descending]
    S2 --> S3[Move current policy first]
    S3 --> D1{Duplicate policy number?}
    D1 -->|Yes| EndErr([ArgumentException])
    D1 -->|No| EndOk([Return SelectList])

Failure and edge-case behavior

  • Duplicate policy numbers across associations break rendering of the whole header.

Sources

  • src/BolMiddleware/Extensions/HeaderExtensions.cs
  • src/BolMiddleware/Pages/Components/BolPolicyHeader/default.cshtml