SecurityOverrideService¶
Implements ISecurityOverrideService to create, update, delete, and enrich security-override records for injury claims, coordinating persistence through IUnitOfWork, rule validation through IValidationService, and current-user/claim lookups through IUserProfileService. It maps SAIF.Data.Model.Claims.SecurityOverrides.SecurityOverride entities to the SAIF.Core.Contracts.Claims.SecurityOverrides.SecurityOverride contract via an AutoMapper mapping registered in its constructor, deriving IsConflictClaim from IsWorkerConflict and IsSecureClaim from whether the hostile-worker code is "R" or "T".
Purpose¶
- Creates and updates security-override records for a claim/employee pair after validating the submitted edit through
IValidationService. - Enriches a security override with computed display data (formatted user name, claim number, worker name) and edit/delete eligibility flags based on effective/expiration dates.
- Deletes an existing security override within a unit-of-work transaction.
- Supplies claim-number and user-ID existence checks (
IsValidClaim,IsValidUserId) used as FluentValidation rule predicates bySecurityOverrideValidator.
Context¶
- Namespace:
SAIF.Services.Claims.SecurityOverride - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| SecurityOverrideService | public SecurityOverrideService(IUnitOfWork uow, IUserProfileService userProfileService, IValidationService validationService) |
Wires the repository/user-profile/validation collaborators and registers the entity-to-contract AutoMapper map for security overrides. |
| GetSecurityOverrideById | public Core.Contracts.Claims.SecurityOverrides.SecurityOverride GetSecurityOverrideById(long id) |
Loads a single security override by its identifier, mapped to the contract type with computed display fields populated. |
| GetSecurityOverrides | public IEnumerable<Core.Contracts.Claims.SecurityOverrides.SecurityOverride> GetSecurityOverrides(bool includeExpired) |
Returns all security overrides, optionally filtering out ones whose expiration date has passed. |
| CreateOverride | public Core.Contracts.Claims.SecurityOverrides.SecurityOverride CreateOverride(SecurityOverrideEdit securityOverrideEdit, IMessageContainer messages) |
Validates the edit, then persists a new security-override record (with hostile-worker code, conflict flag, and audit stamps) in a unit-of-work transaction; returns an empty contract instance when validation fails. |
| UpdateOverride | public bool UpdateOverride(long id, SecurityOverrideEdit updateOverride, IMessageContainer messages) |
Validates the edit, rejects the update as a concurrency conflict if the stored UpdateDate no longer matches, and otherwise persists the new effective/expiration dates and audit stamps; returns whether the update succeeded. |
| DeleteOverride | public bool DeleteOverride(long id, IMessageContainer messageContainer) |
Deletes the matching security-override record in a unit-of-work transaction; returns false if no record is found. |
| IsValidClaim | public bool IsValidClaim(string claimNum) |
Reports whether an injury claim exists with the given claim number (case-insensitive by uppercasing). |
| IsValidUserId | public bool IsValidUserId(string userId) |
Reports whether the given user ID resolves to an application user with a non-empty last name. |
Behavioral notes¶
CreateOverride,UpdateOverride, andDeleteOverridewrap their writes inIUnitOfWork.Begin()/Commit()(orRollback()on a detected concurrency conflict).UpdateOverrideimplements optimistic-concurrency checking by comparing the incomingUpdateDateagainst the stored record before applying changes.SetAdditionalProperties* (private) computesCanEdit/CanDeletefrom the override's expiration/effective dates relative toDateTime.Today.- Validation is delegated to
IValidationService.Validate, with FluentValidation errors added to the suppliedIMessageContainer.
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.
Sources¶
- Services/SAIF.Services/Claims/SecurityOverride/SecurityOverrideService.cs