Created
September 2, 2022 21:22
-
-
Save fnbk/2ea9b6253c11005fb88be10985c25719 to your computer and use it in GitHub Desktop.
branching: local-functions
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
private Job CreateJob(order order) | |
{ | |
var job = ValidateComputer(order.ComputerName, onSuccess, onFailure); | |
return job; | |
Job onSuccess(Order order) | |
{ | |
var computer = GetComputer(order.ComputerName, order.CustomerId); | |
computer.CustomerId = GetCustomerId(order.CustomerId, computer.CustomerId); | |
var siteServerAddress = GetServerAddress(order.ComputerName, computer.CustomerId); | |
var deploymentType = GetDeploymentType(order.MaterialNumber, computer.CustomerId); | |
return new Job() | |
{ | |
ActivationTime = order.ClientLocalStartTime, | |
ComputerName = order.ComputerName, | |
orderId = order.Id, | |
JobActions = CreateJobActions(deploymentType, order, siteServerAddress, computer), | |
Status = "created", | |
} | |
} | |
Job onFailure(Order order) | |
{ | |
return new Job() | |
{ | |
ActivationTime = order.ClientLocalStartTime, | |
ComputerName = order.ComputerName, | |
orderId = order.Id, | |
Status = invalidComputerErrorMessage, | |
}; | |
} | |
} | |
private Job ValidateComputer(Order order, Func<Order, Job> onSuccess, Func<Order, Job> onFailure); | |
{ | |
bool valid = !String.IsNullOrEmpty(order.ComputerName); | |
if (valid) | |
{ | |
return onSuccess(order); | |
} | |
return onFailure(order); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment