Skip to content

Commit

Permalink
SA Youth: ensure 'HasCertification' of type 'NonAccreditedCertificati…
Browse files Browse the repository at this point in the history
…on' when 'VerificationEnabled'; Yoma's certification is not accredited (#1111)

Access Rules: Fixed issue with completed opporunity comparisons
  • Loading branch information
adrianwium authored Sep 23, 2024
1 parent ccbd430 commit 9ca9e70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Transactions;
using Yoma.Core.Domain.Core;
using Yoma.Core.Domain.Core.Exceptions;
using Yoma.Core.Domain.Core.Extensions;
using Yoma.Core.Domain.Core.Helpers;
using Yoma.Core.Domain.Core.Interfaces;
using Yoma.Core.Domain.Core.Models;
Expand Down Expand Up @@ -531,18 +532,18 @@ public StoreAccessControlRuleEvaluationResult EvaluateStoreAccessControlRules(St

var opportunityLinks = rule.Opportunities.Select(o => new StoreAccessControlRuleEvaluationItemReasonLink
{
Title = o.Title,
Title = o.Title.RemoveSpecialCharacters(),
URL = o.YomaInfoURL(_appSettings.AppBaseURL),
RequirementMet = myOpportunitiesCompleted?.Any(i => i.Id == o.Id) == true // check if user completed the opportunity
RequirementMet = myOpportunitiesCompleted?.Any(i => i.OpportunityId == o.Id) == true // check if user completed the opportunity
}).ToList();

if (rule.OpportunityOption == null)
throw new InvalidOperationException($"Opportunity option expected for rule '{rule.Name}'");

var conditionPassed = rule.OpportunityOption.Value switch
{
StoreAccessControlRuleOpportunityCondition.All => rule.Opportunities.All(o => myOpportunitiesCompleted?.Any(i => i.Id == o.Id) == true),
StoreAccessControlRuleOpportunityCondition.Any => rule.Opportunities.Any(o => myOpportunitiesCompleted?.Any(i => i.Id == o.Id) == true),
StoreAccessControlRuleOpportunityCondition.All => rule.Opportunities.All(o => myOpportunitiesCompleted?.Any(i => i.OpportunityId == o.Id) == true),
StoreAccessControlRuleOpportunityCondition.Any => rule.Opportunities.Any(o => myOpportunitiesCompleted?.Any(i => i.OpportunityId == o.Id) == true),
_ => throw new InvalidOperationException($"Opportunity option '{rule.OpportunityOption}' not supported")
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ private OpportunitySkillingUpsertRequest ToRequestUpsert(OpportunityRequestUpser
SponsoringPartner = request.OrganizationYoma.Name.RemoveSpecialCharacters().TrimToLength(200),
Title = request.Opportunity.Title.RemoveSpecialCharacters().TrimToLength(200),
Description = request.Opportunity.Description,
// ensure 'HasCertification' of type 'NonAccreditedCertification' when 'VerificationEnabled'; Yoma's certification is not accredited
HasCertification = request.Opportunity.VerificationEnabled ? YesNoOption.Yes : YesNoOption.No,
CertificationType = request.Opportunity.VerificationEnabled ? CertificateType.AccreditedCertification.ToString() : null,
CertificationDescription = request.Opportunity.Summary,
CertificationType = request.Opportunity.VerificationEnabled ? CertificateType.NonAccreditedCertification.ToString() : null,
CertificationDescription = request.Opportunity.VerificationEnabled ? request.Opportunity.Summary : null,
CloseDate = request.Opportunity.DateEnd,
Duration = request.Opportunity.ToDuration(),
Requirements = "Instructions can be found in the description",
Expand Down

0 comments on commit 9ca9e70

Please sign in to comment.