Skip to content

Instantly share code, notes, and snippets.

@petmat
Created May 14, 2019 20:26
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 petmat/d41fcc75f2ec312dd866a817124e8cf6 to your computer and use it in GitHub Desktop.
Save petmat/d41fcc75f2ec312dd866a817124e8cf6 to your computer and use it in GitHub Desktop.
[FunctionName("Counter")]
public static async Task Counter(
[EntityTrigger] IDurableEntityContext ctx)
{
int currentValue = ctx.GetState<int>();
int operand = ctx.GetInput<int>();
switch (ctx.OperationName)
{
case "add":
currentValue += operand;
break;
case "subtract":
currentValue -= operand;
break;
case "reset":
await SendResetNotificationAsync();
currentValue = 0;
break;
}
ctx.SetState(currentValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment