Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
use request body instead
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKorchemniy committed Dec 6, 2023
1 parent 402f930 commit 33c31a8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions AddInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ public async Task<IActionResult> Run(
ILogger log,
string companyName)
{
log.LogInformation("C# AddInventory function processed a request.");
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);

Check warning on line 35 in AddInventory.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

Converting null literal or possible null value to non-nullable type.

Check warning on line 35 in AddInventory.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

Converting null literal or possible null value to non-nullable type.

if (data == null || data.inventoryName == null)

Check warning on line 37 in AddInventory.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

Dereference of a possibly null reference.

Check warning on line 37 in AddInventory.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

Dereference of a possibly null reference.
{
return new BadRequestObjectResult("Please provide 'inventoryName' in the request body.");
}

log.LogInformation($"Name: {data.inventoryName}");

Check warning on line 42 in AddInventory.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

Dereference of a possibly null reference.

Check warning on line 42 in AddInventory.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

Dereference of a possibly null reference.

Inventory newInventory = new()
{
id = Guid.NewGuid().ToString(),
name = req.Query["inventoryName"],
id = data!.inventoryName,
name = data!.inventoryName,
companyName = companyName
};

Expand Down

0 comments on commit 33c31a8

Please sign in to comment.