Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/CourseTodo.Api/DeleteTodo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
Expand All @@ -20,14 +21,19 @@ public static async Task<HttpResponseMessage> Run(
{
try
{
if (string.IsNullOrEmpty(id))
if (string.IsNullOrEmpty(id))
return req.CreateResponse(HttpStatusCode.OK);

var documentLink = UriFactory.CreateDocumentUri(Constants.DatabaseId, Constants.CollectionId, id);

using var client = DocumentDbClient.GetClient();

await client.DeleteDocumentAsync(documentLink);
var requestOptions = new RequestOptions
{
PartitionKey = new PartitionKey(id)
};

await client.DeleteDocumentAsync(documentLink, requestOptions);

return req.CreateResponse(HttpStatusCode.OK);
}
Expand Down