Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created July 12, 2016 03:22
Show Gist options
  • Save beachside-project/6bd80ce4a8d30aea4afa52fd6a0f7f94 to your computer and use it in GitHub Desktop.
Save beachside-project/6bd80ce4a8d30aea4afa52fd6a0f7f94 to your computer and use it in GitHub Desktop.
SandwichOrder_BuildForm
public static IForm<SandwichOrder> BuildForm()
{
return new FormBuilder<SandwichOrder>()
.Message("サンドイッチボットへようこそ♪")
.Field(nameof(Toppings),
validate: async (state, value) =>
{
var values = ((List<object>)value).OfType<ToppingOptions>();
var result = new ValidateResult() { IsValid = true, Value = values };
if (values != null && values.Contains(ToppingOptions.Everything))
{
result.Value = Enum.GetValues(typeof(ToppingOptions)).Cast<ToppingOptions>()
.Where(t => t != ToppingOptions.Everything && !values.Contains(t)).ToList();
}
return result;
})
.Message("{Toppings}を選択しました。")
.Build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment