Exemplo n.º 1
0
        public async Task <Snapshot <T> > CreatedAsync <T>(T value, CancellationToken cancellationToken = default, SnapshotType?type = null, string committer = null, string reason = null)
            where T : IHasId, IHasEntityType
        {
            var snapshot = new Snapshot <T>
            {
                Time        = DateTime.UtcNow,
                CommitterId = committer ?? _claims.Id,
                Type        = type ?? SuitableType,
                EntityType  = value.Type,
                EntityId    = value.Id,
                Event       = SnapshotEvent.Creation,
                Reason      = reason ?? _claims.GetReason(),
                Value       = value
            };

            await _snapshots.UpdateAsync(snapshot, cancellationToken);

            _logger.LogInformation("Created {0}", snapshot);

            return(snapshot);
        }