From 3c1e92872040e2bc2294364080692e62b9d6de99 Mon Sep 17 00:00:00 2001 From: adrianwium <82496337+adrianwium@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:03:45 +0200 Subject: [PATCH] Opporunity title now strips special characters and ensure ordering by title (#1112) --- .../Marketplace/Services/StoreAccessControlRuleService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/src/domain/Yoma.Core.Domain/Marketplace/Services/StoreAccessControlRuleService.cs b/src/api/src/domain/Yoma.Core.Domain/Marketplace/Services/StoreAccessControlRuleService.cs index abb389298..030502f6f 100644 --- a/src/api/src/domain/Yoma.Core.Domain/Marketplace/Services/StoreAccessControlRuleService.cs +++ b/src/api/src/domain/Yoma.Core.Domain/Marketplace/Services/StoreAccessControlRuleService.cs @@ -312,6 +312,9 @@ await _executionStrategyService.ExecuteInExecutionStrategyAsync(async () => scope.Complete(); }); + if (result.Opportunities?.Count == 0) result.Opportunities = null; + result.Opportunities = result.Opportunities?.OrderBy(o => o.Title).ToList(); + _memoryCache.Remove(CacheHelper.GenerateKey()); return result; @@ -405,6 +408,7 @@ await _executionStrategyService.ExecuteInExecutionStrategyAsync(async () => }); if (result.Opportunities?.Count == 0) result.Opportunities = null; + result.Opportunities = result.Opportunities?.OrderBy(o => o.Title).ToList(); _memoryCache.Remove(CacheHelper.GenerateKey()); @@ -721,7 +725,7 @@ private void ValidateRuleDuplicatesAcrossOrganizations(StoreAccessControlRuleReq var opportunityMessage = duplicateRule.OpportunityOption == StoreAccessControlRuleOpportunityCondition.All ? "Must complete the following opportunities:" : "Must complete at least one of the following opportunities:"; - var opportunityTitles = string.Join(", ", duplicateRule.Opportunities.Select(o => o.Title)); + var opportunityTitles = string.Join(", ", duplicateRule.Opportunities.Select(o => o.Title.RemoveSpecialCharacters())); reasons.Add($"{opportunityMessage} {opportunityTitles}."); }