-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathCommandService.cs
More file actions
29 lines (26 loc) · 1.05 KB
/
CommandService.cs
File metadata and controls
29 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.Text.Json.Serialization;
using Bookings.Payments.Domain;
using Eventuous;
using Eventuous.Extensions.AspNetCore.Http;
namespace Bookings.Payments.Application;
public class CommandService : CommandService<PaymentState> {
public CommandService(IEventStore store) : base(store) {
On<PaymentCommands.RecordPayment>()
.InState(ExpectedState.New)
.GetStream(cmd => GetStream(cmd.PaymentId))
.Act(cmd => [new PaymentEvents.PaymentRecorded(cmd.BookingId, cmd.Amount, cmd.Currency, cmd.Method, cmd.Provider)]);
}
}
// [AggregateCommands(typeof(Payment))]
public static class PaymentCommands {
[HttpCommand]
public record RecordPayment(
string PaymentId,
string BookingId,
float Amount,
string Currency,
string Method,
string Provider,
[property: JsonIgnore] string PaidBy
);
}