public async Task <Note[]> Post(Query query) { var returnValue = new Collection <Note>(); var documentSerivce = new NoteDocumentService(); var client = await documentSerivce.GetClientAsync(); var queryOptions = new FeedOptions { MaxItemCount = -1 }; IDocumentQuery <Note> noteQuery = client.CreateDocumentQuery <Note>( UriFactory.CreateDocumentCollectionUri(NoteDocumentService.DocumentDatabaseName, NoteDocumentService.DocumentCollectionName), queryOptions) .Where(t => t.Content.Contains(query.QueryString)) .AsDocumentQuery(); while (noteQuery.HasMoreResults) { foreach (var note in await noteQuery.ExecuteNextAsync <Note>().ConfigureAwait(false)) { returnValue.Add(note); } } return(returnValue.ToArray()); }
public async Task <HttpResponseMessage> Delete(string id) { try { var documentSerivce = new NoteDocumentService(); var client = await documentSerivce.GetClientAsync(); await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(NoteDocumentService.DocumentDatabaseName, NoteDocumentService.DocumentCollectionName, id)); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.ToString())); } }
public async Task <Note> Put(string id, Note note) { try { var documentSerivce = new NoteDocumentService(); var client = await documentSerivce.GetClientAsync(); await client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(NoteDocumentService.DocumentDatabaseName, NoteDocumentService.DocumentCollectionName, id), note); } catch (Exception ex) { Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ToString()); } return(note); }