public async Task AddViews(string documentId, CouchDbViews views) { var fullDocumentId = $"_design/{documentId}"; using (var client = new MyCouchClient(DbConnectionInfo)) { var existingDoc = await client.Documents.GetAsync(fullDocumentId); var docJson = JsonConvert.SerializeObject(views); DocumentHeaderResponse response; if (!string.IsNullOrEmpty(existingDoc.Id)) { response = await client.Documents.PutAsync(fullDocumentId, existingDoc.Rev, docJson); } else { response = await client.Documents.PutAsync(fullDocumentId, docJson); } if (!response.IsSuccess) { _logger.Error($"unable to add or update document: {documentId} - error: {response.Reason}"); throw new CouldNotCompleteOperationException($"unable to add view: {documentId} - error: {response.Reason}"); } } }
public async Task AddViews(string documentId, CouchDbViews views) { await _innerDocumentDbService.AddViews(documentId, views); }