Skip to content

Commit

Permalink
PC-770: Refactor validity & forward destination logic for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn-Clarke committed Jan 10, 2025
1 parent c30694c commit 33038fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
12 changes: 6 additions & 6 deletions SeaPublicWebsite.BusinessLogic/Services/QuestionFlowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,12 @@ private QuestionFlowStep OtherHeatingTypeForwardDestination(QuestionFlowStep? en

private QuestionFlowStep HeatingControlsForwardDestination(QuestionFlowStep? entryPoint)
{
// If entrypoint is HeatingType, we must ask the other followup question on this route
if (entryPoint is QuestionFlowStep.HeatingType) return QuestionFlowStep.HotWaterCylinder;

return entryPoint is not null
? QuestionFlowStep.AnswerSummary
: QuestionFlowStep.HotWaterCylinder;
return entryPoint switch
{
QuestionFlowStep.HeatingType => QuestionFlowStep.HotWaterCylinder,
null => QuestionFlowStep.HotWaterCylinder,
_ => QuestionFlowStep.AnswerSummary
};
}

private QuestionFlowStep HotWaterCylinderForwardDestination(QuestionFlowStep? entryPoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ public class HeatingControlsViewModel : QuestionFlowViewModel
ErrorMessageResourceName = nameof(ErrorMessages.HeatingControlsRequired))]
public List<HeatingControls> HeatingControls { get; set; } = [];

public bool HeatingControlsIsValid => !(HeatingControls.Count == 0 ||
((HeatingControls.Contains(BusinessLogic.Models.Enums.HeatingControls
.DoNotKnow) ||
HeatingControls.Contains(BusinessLogic.Models.Enums.HeatingControls
.None)) && HeatingControls.Count > 1));
public bool HeatingControlsIsValid
{
get
{
bool containsExclusiveOption = HeatingControls.Contains(BusinessLogic.Models.Enums.HeatingControls.None) ||
HeatingControls.Contains(
BusinessLogic.Models.Enums.HeatingControls.DoNotKnow);
if (containsExclusiveOption) return HeatingControls.Count == 1;
return HeatingControls.Count > 0;
}
}
}

0 comments on commit 33038fc

Please sign in to comment.