â Revalidate Command Documentation
â QUICK DOCUMENTATIONâ
- File Path: /Application/Jobs/Commands/Revalidate/RevalidateCommand.cs
- Primary Purpose: Validates assets and components against business rules and updates the validation status
- Key Methods:
Handle- Loads assets, triggers validation, and saves validation resultsValidate- Called on assets and components to check business rule compliance
- Used By: ImportLogController (Revalidate endpoint)
- Related Models:
- Asset
- Component
- ValuationProfile
- AssetClass
- Job
đī¸ DETAILED DOCUMENTATIONâ
đī¸ Overviewâ
The Revalidate command service performs validation of assets and components against business rules. Unlike the RefreshJobData command, it focuses on identifying and recording validation issues rather than calculating values. It uses the IValidationService to check for errors and warnings in the data and updates the entities with validation results.
đ§ Service Detailsâ
- Namespace: AVP.Application.Jobs.Commands.Revalidate
- Dependencies:
- IApplicationDbContext
- ILogger
- ICurrentUserService
- IValidationService
- Interfaces Implemented:
IRequestHandler<RevalidateCommand, int>
đ Methodsâ
â Handleâ
- Signature:
public async Task<int> Handle(RevalidateCommand request, CancellationToken cancellationToken) - Description: Processes the revalidation command by loading assets and validating them
- Parameters:
request(RevalidateCommand): Contains the JobId to revalidatecancellationToken(CancellationToken): Cancellation token
- Returns: Count of modified entities after validation
đ Implementation Detailsâ
The method follows these steps:
- Loads all ValuationProfiles with their ValuationProfileScores
- Loads all assets for the specified job with their related data
- For each asset:
- Calls CreateValuation() to set up valuation data
- For each component, loads its ValuationProfile and calls CreateValuation()
- Uses the IValidationService to validate each component
- Uses the IValidationService to validate the asset
- Saves changes for any entities modified during validation
- Returns count of modified entities
đ Business Rules Appliedâ
- Assets and components must meet various validation rules to be considered valid
- The IValidationService applies business rules and populates Errors and Warnings dictionaries
- Validation checks data completeness, consistency, and business logic compliance
- The system tracks validation results within the entities themselves
đ Business Processes Supportedâ
- Data quality validation
- Business rule compliance checking
- Error and warning reporting
- Asset and component data verification
⥠Performance Considerationsâ
âšī¸ Note: Validation can be resource-intensive for large datasets. Consider validating in batches for jobs with many assets.
â ī¸ Validation Rules Categoriesâ
The validation service checks for several categories of issues:
-
Missing Required Data
- Components missing required fields
- Assets missing classification or valuation data
- Missing valuation parameters
-
Data Consistency
- Valuation approach matches available data
- Component hierarchy integrity
- Date consistency (acquisition dates, valuation dates)
-
Business Logic
- Valid condition scores
- Appropriate valuation profiles
- Asset/component relationship integrity
đĄ Tip: The validation results can be used to generate data quality reports for clients before finalizing valuations.