Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Last active February 8, 2018 12:52
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 dcomartin/b0942015ce5e09ddeeef0e2539400495 to your computer and use it in GitHub Desktop.
Save dcomartin/b0942015ce5e09ddeeef0e2539400495 to your computer and use it in GitHub Desktop.
public interface IBankAccountGrain : IGrainWithGuidKey
{
Task Deposit(decimal amount);
Task Withdraw(decimal amount);
Task<decimal> Balance();
}
public class BankAccountGrain : JournaledGrain<BankAccountState>, IBankAccountGrain
{
public Task Deposit(decimal amount)
{
RaiseEvent(new Deposited
{
Amount = amount
});
return ConfirmEvents();
}
public Task Withdraw(decimal amount)
{
RaiseEvent(new Withdrawn
{
Amount = amount
});
return ConfirmEvents();
}
public Task<decimal> Balance()
{
return Task.FromResult(State.Balance);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment