protected override async Task OnCommandExecutedAsync( IGangCommand command, GangState <HostState> state ) { await base.OnCommandExecutedAsync(command, state); if (!state.HasErrors) { state = state.AddResult( command.Audit.MemberId, new GangNotify( id: command.GetTypeName(), type: GangNotificationTypes.Success, data: new { type = command.GetTypeName(), data = command.Data } ) ); } var results = state.GetResults(command.Audit); foreach (var result in results) { await Controller.SendCommandAsync( result.Command, result.SendToMemberIds, command.Audit.Version ); } }
async Task <GangState <TStateData> > IGangCommandExecutor <TStateData> .ExecuteAsync(GangState <TStateData> state, IGangCommand command) { var dataTypeName = command.GetTypeName(); if (!_handlers.ContainsKey(dataTypeName)) { throw new GangCommandHandlerNotFoundExcetion(); } var handler = _handlers[dataTypeName]; return(await handler.HandleAsync(state, command)); }