Skip to content

Commit aa19cbe

Browse files
committed
Bug fixes for Orleans Bank Account sample.
Balance now updates after Deposit or Withdraw operations. Withdraw decrements now instead of incorrectly incrementing.
1 parent 4445cff commit aa19cbe

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

orleans/BankAccount/AccountTransfer.Grains/AccountGrain.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace AccountTransfer.Grains;
66

7-
[GenerateSerializer, Immutable]
8-
public record class Balance
7+
[GenerateSerializer]
8+
public class class Balance
99
{
10-
public int Value { get; init; } = 1_000;
10+
public int Value { get; set; } = 1_000;
1111
}
1212

1313
[Reentrant]
@@ -21,7 +21,7 @@ public AccountGrain(
2121

2222
public Task Deposit(int amount) =>
2323
_balance.PerformUpdate(
24-
balance => balance with { Value = balance.Value + amount });
24+
balance => balance.Value += amount);
2525

2626
public Task Withdraw(int amount) =>
2727
_balance.PerformUpdate(balance =>
@@ -34,7 +34,7 @@ public Task Withdraw(int amount) =>
3434
$" This account has {balance.Value} credits.");
3535
}
3636

37-
return balance with { Value = balance.Value + amount };
37+
balance = balance.Value -= amount;
3838
});
3939

4040
public Task<int> GetBalance() =>

0 commit comments

Comments
 (0)