BolPolicyModel¶
Abstract page model at the top of the BOL chain. It adds the policy header: it loads the header for the context policy, checks the user's access, derives the parent account, and decides whether the policy dropdown is shown.
Purpose¶
- Validate that the current user may view the context policy; enforcement is soft (BR-BOLMIDDLEWARE-009).
- Reset and derive the parent account (BR-BOLMIDDLEWARE-010, BR-BOLMIDDLEWARE-011).
- Decide dropdown visibility (BR-BOLMIDDLEWARE-012).
- Reuse the session header when it matches (BR-BOLMIDDLEWARE-014).
- Show the error view when an error message is set (BR-BOLMIDDLEWARE-017).
Context¶
- Namespace:
BolMiddleware.Models - Assembly/package:
BolMiddleware
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| Constructor | BolPolicyModel(IBolServicesContainer services, IPolicyHeaderService headerService) |
Receives the container and the policy header facade. |
Header |
PolicyHeader? Header { get; protected set; } |
Header for the context policy, rendered by the policy header component. |
ErrorMessage |
string? ErrorMessage { get; protected set; } |
Message shown in the error view when loading or validation fails. |
AccessAllowed |
bool AccessAllowed { get; protected set; } |
Result of the policy access check; derived pages must test it because the handler still runs. |
ParentAccount |
long ParentAccount { get; protected set; } |
Parent account number derived from the header. |
ShowPolicyDropdown |
bool ShowPolicyDropdown { get; protected set; } |
Whether the layout shows the policy dropdown instead of a label. |
OnPageHandlerExecuting |
override void OnPageHandlerExecuting(PageHandlerExecutingContext context) |
Runs the base logic, then loads the header and validates access. |
OnPageHandlerExecuted |
override void OnPageHandlerExecuted(PageHandlerExecutedContext context) |
Runs the base save and the end hook. |
OnRequestStart |
virtual void OnRequestStart() |
Hook invoked before the policy logic. |
OnRequestEnd |
virtual void OnRequestEnd() |
Hook invoked after the handler. |
TryGetPolicyHeader |
protected bool TryGetPolicyHeader() |
Loads the header for the context policy and records an error message on failure. |
GetPolicyHeader |
protected PolicyHeader GetPolicyHeader(long policyNumber, long? customerId, string? userTypeCode) |
Returns the header from session or the Policy Header API. |
CanViewPolicyDropdown |
protected bool CanViewPolicyDropdown(bool isUserExternal) |
Applies the dropdown visibility rule for internal and external users. |
Behavioral notes¶
- The policy access check blocks on an async call through
Task.Result. ex.Messageis stored inErrorMessageand shown to the user.
Constraints and usage notes¶
- A failed access check does not stop the handler; see Security and authorization.
Sources¶
- src/BolMiddleware/Models/BolPolicyModel.cs