Created
September 21, 2020 07:46
-
-
Save laur3d/b124e715acc90513ef4017acd82b37d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("RemoveItemFromCart")] | |
public static async Task<IActionResult> RunAsync( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "cart/{id}/remove")] HttpRequestMessage req, | |
Guid id, | |
[DurableClient] IDurableClient client, ILogger log) | |
{ | |
if (id == Guid.Empty) | |
{ | |
return (ActionResult) new BadRequestObjectResult("Id is required"); | |
} | |
var entityId = new EntityId(nameof(ShoppingCartEntity),id.ToString()); | |
var data = await req.Content.ReadAsAsync<CartItem>(); | |
await client.SignalEntityAsync<IShoppingCart>(entityId, proxy => proxy.Remove(data)); | |
return (ActionResult) new AcceptedResult(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment