Created
May 14, 2019 20:26
-
-
Save petmat/d41fcc75f2ec312dd866a817124e8cf6 to your computer and use it in GitHub Desktop.
This file contains 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
[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