using Core.Entities;
using Core.Models;
using Core.Validation.Rules.BaseRules;
namespace Core.Validation.Rules.StudentAssignmentRules;
///
/// Validation rule that checks if a student has too many event assignments
///
public class TooManyEventsRule : EventCountThresholdRuleBase
{
protected override int GetCount(StudentEventStatistics statistics) => statistics.EventCount;
protected override int GetThreshold(ValidationConfiguration config) => config.MaxRecommendedEvents;
protected override bool ViolatesThreshold(int count, int threshold) => count > threshold;
protected override ValidationSeverity GetBaseSeverity(ValidationConfiguration config) => config.EventCountSeverity;
protected override int? GetCriticalThreshold(ValidationConfiguration config) => config.MaxCriticalEvents;
protected override bool ViolatesCriticalThreshold(int count, int criticalThreshold) => count > criticalThreshold;
protected override string Code => "TOO_MANY_EVENTS";
protected override string GetMessage(int count, int threshold) =>
$"Student has {count} events (max recommended: {threshold})";
protected override Dictionary BuildAdditionalMetadata(StudentEventStatistics statistics, ValidationConfiguration config)
{
return new Dictionary
{
{ "MaxRecommended", config.MaxRecommendedEvents },
{ "MaxCritical", config.MaxCriticalEvents }
};
}
}