private void ValidateCampaignPriorityRounds(CampaignPriorityRoundsModel campaignPriorityRounds) { campaignPriorityRounds?.PopulateRoundNumbers(); var validationResult = CampaignPriorityRoundsModelValidations.ValidateCampaignPriorityRounds(campaignPriorityRounds); if (!string.IsNullOrWhiteSpace(validationResult)) { throw new Exception($"Scenario {nameof(CampaignPriorityRoundsModel)} contains error: {validationResult}"); } }
public static string ValidateCampaignPriorityRounds(CampaignPriorityRoundsModel campaignPriorityRounds) { var cprErrors = new StringBuilder(); if (campaignPriorityRounds?.Rounds?.Any() == true) { if (!_campaignPriorityRoundsModelValidator.IsValid(campaignPriorityRounds)) { _campaignPriorityRoundsModelValidator.Errors.ForEach(e => cprErrors.AppendLine(e.ErrorMessage)); } } return(cprErrors.ToString()); }