---
title: BolPolicyModel
summary: API reference for BolPolicyModel.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
---

# 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](../../business-rules.md#br-bolmiddleware-009-policy-access-validation)).
- Reset and derive the parent account ([BR-BOLMIDDLEWARE-010](../../business-rules.md#br-bolmiddleware-010-parent-account-reset), [BR-BOLMIDDLEWARE-011](../../business-rules.md#br-bolmiddleware-011-parent-account-derivation)).
- Decide dropdown visibility ([BR-BOLMIDDLEWARE-012](../../business-rules.md#br-bolmiddleware-012-policy-dropdown-visibility)).
- Reuse the session header when it matches ([BR-BOLMIDDLEWARE-014](../../business-rules.md#br-bolmiddleware-014-session-policy-header-reuse)).
- Show the error view when an error message is set ([BR-BOLMIDDLEWARE-017](../../business-rules.md#br-bolmiddleware-017-error-message-error-view)).

## 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
- A failed access check does not stop the handler; see [Security and authorization](../../security-authorization.md).

## Sources
- src/BolMiddleware/Models/BolPolicyModel.cs
