Skip to content

Instantly share code, notes, and snippets.

@laur3d
Created September 21, 2020 07:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
[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