Skip to content

Instantly share code, notes, and snippets.

@dcomartin dcomartin/grain.cs
Last active Feb 8, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.