示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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()));
        }