Skip to content

Commit

Permalink
review: using
Browse files Browse the repository at this point in the history
  • Loading branch information
nijmra committed Nov 25, 2024
1 parent 3ab4f22 commit 2464b6c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<IActionResult> Put(string version, Guid uuid, PublicatieDocume
}

// document bijwerken
var putResponse = await client.PutAsJsonAsync(url, document, token);
using var putResponse = await client.PutAsJsonAsync(url, document, token);

putResponse.EnsureSuccessStatusCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ public async Task<IActionResult> Get(string version, Guid uuid, CancellationToke

var json = await response.Content.ReadFromJsonAsync<PublicatieDocument>(token);

if (json?.Eigenaar?.identifier != user.Id)
{
return NotFound();
}

return new DocumentDownloadResult(Request.Path, "Document downloaden");
return json?.Eigenaar?.identifier != user.Id ? NotFound() : new DocumentDownloadResult(Request.Path, "Document downloaden");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ public class InitialiseerDocumentController(IOdrcClientFactory clientFactory) :
public async Task<IActionResult> Post(string version, PublicatieDocument document, CancellationToken token)
{
using var client = clientFactory.Create("Initialiseer document");

var url = $"/api/{version}/documenten";

var response = await client.PostAsJsonAsync(url, document, token);
using var response = await client.PostAsJsonAsync(url, document, token);

response.EnsureSuccessStatusCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public async Task<IActionResult> Put(string version, Guid docUuid, Guid partUuid
content.Add(fileContent, "inhoud", file.FileName);

using var client = clientFactory.Create("Upload bestandsdeel");

var url = $"/api/{version}/documenten/{docUuid}/bestandsdelen/{partUuid}";

var response = await client.PutAsync(url, content, token);
using var response = await client.PutAsync(url, content, token);

response.EnsureSuccessStatusCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task<IActionResult> Put(string version, Guid uuid, Publicatie publi
}

// publicatie bijwerken
var putResponse = await client.PutAsJsonAsync(url, publicatie, token);
using var putResponse = await client.PutAsJsonAsync(url, publicatie, token);

putResponse.EnsureSuccessStatusCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ public async Task<IActionResult> Post(string version, Publicatie publicatie, Can
}

using var client = clientFactory.Create("Publicatie registreren");

var url = $"/api/{version}/publicaties";

var response = await client.PostAsJsonAsync(url, publicatie, token);
using var response = await client.PostAsJsonAsync(url, publicatie, token);

response.EnsureSuccessStatusCode();

Expand Down

0 comments on commit 2464b6c

Please sign in to comment.