public async Task <TAggregate> TryGetAsync(Guid aggregateId) { var partitionKey = AggregateKeysBuilder.BuildPartitionKey(aggregateId); var rowKey = AggregateKeysBuilder.BuildRowKey(aggregateId); var entity = await _storage.GetDataAsync(partitionKey, rowKey); if (entity != null) { return(await _mapEntityToAggregate(entity)); } return(null); }
public async Task <TAggregate> GetOrAddAsync(Guid aggregateId, Func <TAggregate> newAggregateFactory) { var partitionKey = AggregateKeysBuilder.BuildPartitionKey(aggregateId); var rowKey = AggregateKeysBuilder.BuildRowKey(aggregateId); var startedEntity = await _storage.GetOrInsertAsync( partitionKey, rowKey, () => { var newAggregate = newAggregateFactory(); return(_mapAggregateToEntity(newAggregate)); }); return(await _mapEntityToAggregate(startedEntity)); }