Exemplo n.º 1
0
        public async Task DeleteAsync(string appId, string id,
                                      CancellationToken ct = default)
        {
            using (Telemetry.Activities.StartActivity("MongoDbChannelTemplateRepository/DeleteAsync"))
            {
                var docId = MongoDbChannelTemplate <T> .CreateId(appId, id);

                await Collection.DeleteOneAsync(x => x.DocId == docId, ct);
            }
        }
Exemplo n.º 2
0
        public async Task UpsertAsync(ChannelTemplate <T> template, string?oldEtag = null,
                                      CancellationToken ct = default)
        {
            using (Telemetry.Activities.StartActivity("MongoDbChannelTemplateRepository/UpsertAsync"))
            {
                var document = MongoDbChannelTemplate <T> .FromChannelTemplate(template);

                await UpsertDocumentAsync(document.DocId, document, oldEtag, ct);
            }
        }
Exemplo n.º 3
0
        public async Task <(ChannelTemplate <T>?Template, string?Etag)> GetAsync(string appId, string code,
                                                                                 CancellationToken ct = default)
        {
            using (Telemetry.Activities.StartActivity("MongoDbChannelTemplateRepository/GetAsync"))
            {
                var docId = MongoDbChannelTemplate <T> .CreateId(appId, code);

                var document = await GetDocumentAsync(docId, ct);

                return(document?.ToChannelTemplate(), document?.Etag);
            }
        }
Exemplo n.º 4
0
        public static MongoDbChannelTemplate <T> FromChannelTemplate(ChannelTemplate <T> template)
        {
            var docId = CreateId(template.AppId, template.Id);

            var result = new MongoDbChannelTemplate <T>
            {
                DocId = docId,
                Doc   = template,
                Etag  = GenerateEtag()
            };

            return(result);
        }