Exemplo n.º 1
0
        private async Task PersistAndPublishAsync(IAggregateNameAggregate aggregate, IMessageHandlerContext context)
        {
            if (aggregate.IsNew)
            {
                await aggregateWriteRepository.CreateAsync(aggregate);
            }
            else
            {
                await aggregateWriteRepository.UpdateAsync(aggregate);
            }

            await Task.WhenAll(aggregate.UncommittedEvents.Select(async(x) => await context.Publish(x)));
        }
Exemplo n.º 2
0
        public async Task DeleteAsync(IAggregateNameAggregate aggregate)
        {
            await using var connection = new MySqlConnection(this.connectionStringProvider.TemplateConnectionString);
            {
                var parameters = new
                {
                    aggregate.Id,
                };

                await connection.ExecuteAsync(this.sqlHelper.GetSqlFromEmbeddedResource("DeleteAggregateName"), parameters,
                                              commandType : CommandType.Text);
            }
        }