Skip to content

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

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.Message is stored in ErrorMessage and shown to the user.

Constraints and usage notes

Sources

  • src/BolMiddleware/Models/BolPolicyModel.cs