Beispiel #1
0
 /// Read the present state
 // TOCONSIDER: you should probably be separating this out per CQRS and reading from a denormalized/cached set of projections
 public Task <View> Read(ClientId id) => _stream(id).Query(Render);
Beispiel #2
0
 public static Target For(ClientId id) => Target.NewAggregateId("Aggregate", id.ToString());
Beispiel #3
0
 /// Maps a ClientId to the Target that specifies the Stream in which the data for that client will be held
 public static Target For(ClientId id) =>
 Target.NewAggregateId("Todos", id?.ToString() ?? "1");
Beispiel #4
0
 /// Execute the specified command
 public Task <Unit> Execute(ClientId id, Command command) =>
 _stream(id).Execute(command);
Beispiel #5
0
 /// Load details for a single specific item
 public Task <View> TryGet(ClientId clientId, int id) =>
 _stream(clientId).Query(s =>
 {
     var i = s.Items.SingleOrDefault(x => x.Id == id);
     return(i == null ? null : Render(i));
 });
Beispiel #6
0
            //
            // READ
            //

            /// List all open items
            public Task <IEnumerable <View> > List(ClientId clientId) =>
            _stream(clientId).Query(s => s.Items.Select(Render));
Beispiel #7
0
 /// Maps a ClientId to the Target that specifies the Stream in which the data for that client will be held
 public static string For(ClientId id) =>
 StreamNameModule.create("Todos", id?.ToString() ?? "1");
Beispiel #8
0
 /// Maps a ClientId to the CatId that specifies the Stream in which the data for that client will be held
 static Target CategoryId(ClientId id) =>
 Target.NewCatId("Todos", id?.ToString() ?? "1");
 public static string For(ClientId id) => StreamNameModule.create("Aggregate", id.ToString());