private void Deleted(DocmsContext ctx, string path, int contentId)
 {
     ctx.DocumentHistories.Add(DocumentHistory.DocumentDeleted(
                                   DateTime.UtcNow,
                                   contentId,
                                   path));
 }
Beispiel #2
0
        public async Task Handle(DomainEventNotification <DocumentDeletedEvent> notification, CancellationToken cancellationToken = default)
        {
            var ev = notification.Event;

            _db.DocumentHistories
            .Add(DocumentHistory.DocumentDeleted(
                     ev.Timestamp,
                     ev.Entity.Id,
                     ev.Path.ToString()));
            await _db.SaveChangesAsync();
        }
        private void Moved(DocmsContext ctx, string from, string to, int contentId)
        {
            var now = DateTime.UtcNow;

            ctx.DocumentHistories.Add(DocumentHistory.DocumentUpdated(
                                          DateTime.UtcNow,
                                          contentId,
                                          to,
                                          "stragekey",
                                          "text/plain",
                                          5 + contentId.ToString().Length,
                                          Hash.CalculateHash(Encoding.UTF8.GetBytes("Hello" + contentId)),
                                          now,
                                          now));
            ctx.DocumentHistories.Add(DocumentHistory.DocumentDeleted(
                                          DateTime.UtcNow,
                                          contentId,
                                          from));
        }
Beispiel #4
0
        public async Task Handle(DomainEventNotification <DocumentMovedEvent> notification, CancellationToken cancellationToken = default)
        {
            var ev = notification.Event;

            _db.DocumentHistories
            .Add(DocumentHistory.DocumentCreated(
                     ev.Timestamp,
                     ev.Entity.Id,
                     ev.NewPath.ToString(),
                     ev.Entity.StorageKey,
                     ev.Entity.ContentType,
                     ev.Entity.FileSize,
                     ev.Entity.Hash,
                     ev.Entity.Created,
                     ev.Entity.LastModified));

            _db.DocumentHistories
            .Add(DocumentHistory.DocumentDeleted(
                     ev.Timestamp,
                     ev.Entity.Id,
                     ev.Path.ToString()));
            await _db.SaveChangesAsync();
        }