예제 #1
0
        public async Task AddAsync(Document doc, Attachment[] attachments)
        {
            doc.Validate();
            doc.RebuildTags();
            doc.RebuildValues();
            await this.documentCollection.InsertOneAsync(doc);

            this.logger.LogInformation("Added document {docid}", doc.Id);

            if (attachments.Length > 0)
            {
                foreach (var attachment in attachments)
                {
                    attachment.DocumentId = doc.Id;
                    attachment.Author     = doc.Author;
                }

                await this.attachmentCollection.InsertManyAsync(attachments);

                this.logger.LogInformation("Added {attachments} for document {docid}", attachments.Length, doc.Id);
            }
        }
예제 #2
0
 public Task AddAsync(Document doc)
 {
     return(this.AddAsync(doc, Array.Empty <Attachment>()));
 }