Beispiel #1
0
        public static async Task <string> CreateToDoTaskAsync(ToDoTasks theTask)
        {
            try{
                await cosmosClient.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, theTask.id));

                //Found
                return("found");
            }
            catch (DocumentClientException de) {
                if (de.StatusCode == HttpStatusCode.NotFound)
                {
                    await cosmosClient.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), theTask);
                }
                else
                {
                    throw;
                }
                return("created");
            }
        }
Beispiel #2
0
        public static async Task <bool> ReplaceTodoTaskAsync(string id, ToDoTasks theTask)
        {
            await cosmosClient.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, id), theTask);

            return(true);
        }