Skip to content

Instantly share code, notes, and snippets.

@Jonne
Created January 28, 2016 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonne/f14a320e446f1c068501 to your computer and use it in GitHub Desktop.
Save Jonne/f14a320e446f1c068501 to your computer and use it in GitHub Desktop.
Maybe in tranformations
private IEnumerable<ProductAdvisorStep> MapSteps(ChildList children)
{
return children.SelectMany(GetStep);
}
private Maybe<ProductAdvisorStep> GetStep(Item item, int index)
{
string facetName =
Context.Database.GetItem(item.Fields[ProductAdvisorDataFields.StepFacetField]?.Value)?.Name;
if (string.IsNullOrEmpty(facetName))
{
logger.Error("A Facet is required for a ProductAdvisorStep.");
return Maybe.Empty<ProductAdvisorStep>();
}
return new ProductAdvisorStep
{
Key = index + 1,
Title = item.Fields[ProductAdvisorDataFields.StepQuestionField].Value,
Facet = facetName
}.ToMaybe();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment