public static Todo ToTodo(this TodoTableEntity entity) { var todo = new Todo { Id = entity.RowKey, CreatedAt = entity.CreatedAt, IsCompleted = entity.IsCompleted, TaskDescription = entity.TaskDescription }; return(todo); }
public static TodoTableEntity ToTableEntity(this Todo todo) { var entity = new TodoTableEntity { PartitionKey = "TODO", RowKey = todo.Id, CreatedAt = todo.CreatedAt, IsCompleted = todo.IsCompleted, TaskDescription = todo.TaskDescription }; return(entity); }
public static IActionResult GetTodoById( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todo/{id}")] HttpRequest req, [Table("todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity entity, ILogger log, string id) { log.LogInformation("Getting todo item by id"); if (entity == null) { log.LogInformation($"item with id: {id} not found"); return(new NotFoundResult()); } return(new OkObjectResult(entity.ToTodo())); }