Skip to content

Instantly share code, notes, and snippets.

Created September 21, 2020 07:47
  • 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
What would you like to do?
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "cart/{id}")] HttpRequestMessage req,
Guid id,
[DurableClient] IDurableClient client,
ILogger log)
if (id == Guid.Empty)
return (ActionResult) new BadRequestObjectResult("The ID is required");
var entityId = new EntityId(nameof(ShoppingCartEntity), id.ToString());
var stateResponse = await client.ReadEntityStateAsync<ShoppingCartEntity>(entityId);
if (!stateResponse.EntityExists)
return (ActionResult) new NotFoundObjectResult("No cart with this id");
var response = stateResponse.EntityState.GetCartItems();
return (ActionResult) new OkObjectResult(response.Result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment