Created
January 19, 2019 16:32
-
-
Save MarcoNicolodi/bfb23065263172fa278d6069e2c09b9c to your computer and use it in GitHub Desktop.
Chain of responsibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected string GetClass(string code, bool approve) | |
{ | |
var evaluation = TrainingEvaluations.Find(x => x.EmployeeCode == code.Split('_')[0] && x.CriteriaCode == code.Split('_')[1]); | |
var criteriaHasEvaluation = evaluation.Any(); | |
var isNew = code.Split('_')[1] == IEntity.NewCode; | |
var effectiveness = TrainingEffectiveness.Find(x => x.EmployeeCode == code.Split('_')[0]); | |
var hasEffectiveness = effectiveness.Any(); | |
if (hasEvaluation) | |
{ | |
return evaluation.HasEvaluation | |
? approve | |
? evaluation.IsApproved | |
? "approvedOn" | |
: "approvedOff" | |
: !evaluation.IsApproved | |
? "reprovedOn" | |
: "reprovedOff" | |
: approve | |
? "approvedOff" | |
: "reprovedOff"; | |
} | |
if (!hasEffectiveness) return approve ? "approvedOff" : "reprovedOff"; | |
if (isNew) return "approvedOff"; | |
switch (effectiveness.IsEffective) | |
{ | |
case 0: | |
return approve ? "approvedOff" : "reprovedOn"; | |
case 1: | |
return approve ? "approvedOn" : "reprovedOff"; | |
default: | |
return approve ? "approvedOff" : "reprovedOff"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment