public static IActionResult GetTodoById( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todos-table/{id}")] HttpRequest req, [Table("todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity todo, ILogger log, string id) { log.LogInformation("Getting todo item by id"); if (todo == null) { log.LogInformation($"Item {id} not found"); return(new NotFoundResult()); } return(new OkObjectResult(todo.ToTodo())); }
public static IActionResult GetItemById( [HttpTrigger(AUTH_LEVEL, METHOD_GET, Route = ROUTE + "/{id}")] HttpRequest req, [Table(AZURE_TABLE, AZURE_TABLE_PARTITION_KEY, "{id}", Connection = AZURE_TABLE_CONNECTION_STRING)] TodoTableEntity todo, TraceWriter log, string id) { log.Info("Getting todo item by id"); if (todo == null) // << The todo is loaded automatically { log.Info($"Item {id} not found"); return(new NotFoundResult()); } return(new OkObjectResult(todo.ToTodo())); }
public static IActionResult GetTodoByIdAsync( [HttpTrigger(AuthorizationLevel.Anonymous, "GET", Route = "todo/{id}")] HttpRequest request, [Table("todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity entity, ILogger logger, Guid id) { logger.LogInformation("Getting todo by id {@id}...", id); if (entity == null) { logger.LogInformation("Item {@Id} not found", id); return(new NotFoundResult()); } return(new OkObjectResult(entity.ToTodo())); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todo2/{id}")] HttpRequest request, [Table("todos", "todo", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity todoTableEntity, ILogger logger) { logger.LogInformation($"Getting todo item by id"); if (todoTableEntity == null) { return(new NotFoundResult()); } var todo = todoTableEntity.ToTodo(); return(new OkObjectResult(todo)); }