public async Task <NLogItemEntity> UpsertAsync(object item) { var bucket = await _provider.GetBucketAsync(_options.Bucket); NLogItemEntity nLogItemEntity; try { var configContent = await CollectionExtensions.GetAsync(bucket.DefaultCollection(), _options.ConfigId); nLogItemEntity = configContent.ContentAs <NLogItemEntity>(); } catch (DocumentNotFoundException e) { nLogItemEntity = new NLogItemEntity(); nLogItemEntity.CreationDate = DateTime.UtcNow; } nLogItemEntity.LastModifiedDate = DateTime.Now; nLogItemEntity.Config = item; await bucket.DefaultCollection().UpsertAsync(_options.ConfigId, nLogItemEntity); return(nLogItemEntity); }