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
public class EffectivenessAssessmentPending : RuleHandler { | |
public override Label Run(Request request) | |
{ | |
if(!request.HasEffectiveness) | |
{ | |
return request.Approve ? Label.ApprovedOff : Label.ReprovedOff; | |
} else { | |
return base.Run(request); | |
} |
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 aprove) | |
{ | |
var request = new Request(code, approve, TrainingEvaluations, TrainningEffectiveness); | |
var chain = new CriteriaHasEvaluation(); | |
chain | |
.SetNext(new EffectivenessAssessmentPending()) | |
.SetNext(new NewItem()) | |
.SetNext(new CriteriaEvaluated()); |
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) |
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
public abstract class RuleHandler<TRequest, TReturn> | |
{ | |
private RuleHandler<TRequest, TReturn> _nextHandler; | |
public RuleHandler<TRequest, TReturn> SetNext(RuleHandler<TRequest, TReturn> handler) | |
{ | |
_nextHandler = handler; | |
return _nextHandler; | |
} |
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
public class EffectivenessAssessmentPending : RuleHandler<Request,Label> { | |
public override Label Run(Request request) | |
{ | |
if(!request.HasEffectiveness) | |
{ | |
return request.Approve ? Label.ApprovedOff : Label.ReprovedOff; | |
} else { | |
return base.Run(request); | |
} |
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
const chooseFile = async ({ directory, message }) => { | |
const candidateFiles = await filesystem.list(directory) | |
const promptConfig = { | |
name: 'chosenFile', | |
message, | |
choices: ['all', prompt.separator(), ...candidateFiles] | |
} | |
const { chosenFile } = await prompt.ask(promptConfig) | |
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
const chooseFile = async ({ directory, message, matching }) => { | |
let candidateFiles | |
if (matching) { | |
candidateFiles = await filesystem.find(directory, { matching }) | |
} else { | |
candidateFiles = await filesystem.list(directory) | |
} | |
const promptConfig = { | |
name: 'chosenFile', |
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
public abstract class FileChooser | |
{ | |
protected abstract Task<IEnumerable<string>> Find(Request request); | |
public async Task<string> Choose(Request request) | |
{ | |
var candidateFiles = await Find(request); | |
var chosenFile = await Prompt.Ask(new { | |
message = request.Message, | |
choices: candidateFiles |
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
public class MatchingFinder : FileChooser | |
{ | |
protected override async Task<IEnumerable<string>> Find(Request request) | |
=> await Filesystem.Find(request.Directory, request.Matching); | |
} | |
public class ListFinder : FileChooser | |
{ | |
protected override async Task<IEnumerable<string>> Find(Request request) | |
=> await Filesystem.List(request.Directory); |
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
if (matching) { | |
candidateFiles = await filesystem.find(directory, { matching }) | |
} else { | |
candidateFiles = await filesystem.list(directory) | |
} |