示例#1
0
 public static Todo ToTodo(this TodoTableEntity todo)
 {
     return(new Todo()
     {
         Id = todo.RowKey,
         CreatedTime = todo.CreatedTime,
         IsCompleted = todo.IsCompleted,
         TaskDescription = todo.TaskDescription
     });
 }
示例#2
0
 public static Todo ToTodo(TodoTableEntity tableEntity)
 {
     return(new Todo
     {
         Id = tableEntity.RowKey,
         CreateedTime = tableEntity.CreateedTime,
         IsCompleted = tableEntity.IsCompleted,
         TaskDescription = tableEntity.TaskDescription
     });
 }
示例#3
0
 public static Todo ToTodo(this TodoTableEntity entity)
 {
     return(new Todo()
     {
         Id = entity.RowKey,
         CreatedTime = entity.CreatedTime,
         IsCompleted = entity.IsCompleted,
         TaskDescription = entity.TaskDescription
     });
 }
示例#4
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 {id} not found");
         return(new NotFoundResult());
     }
     return(new OkObjectResult(entity.ToTodo()));
 }
 public static async Task <IActionResult> GetTodoById(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "mission/{id}")] HttpRequest req,
     [Table("Todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity todo,
     TraceWriter log, string id)
 {
     log.Info("Getting todo item by id");
     if (todo == null)
     {
         log.Info($"Item {id} not found");
         return(new NotFoundResult());
     }
     return(new OkObjectResult(todo.ToTodo()));
 }
示例#6
0
        public static IActionResult GetTodoById([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todo/{id}")] HttpRequest req,
                                                [Table("todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity todo, //With this we tell the storage to search with the given id
                                                TraceWriter log, string id)
        {
            log.Info("Getting todo item by id");

            if (todo == null)
            {
                log.Error($"Item {id} not found");
                return(new NotFoundResult());
            }

            return(new OkObjectResult(todo.ToTodo()));
        }
示例#7
0
        public static async Task <IActionResult> GetTodoById([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todo/{id}")] HttpRequest req, ILogger log, string id,
                                                             [Table("todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity todo)
        {
            log.LogInformation("Getting a specific todo list item by its Id.");

            if (id == Guid.Empty.ToString() || id == string.Empty)
            {
                return(new BadRequestObjectResult("invalid Id"));
            }

            if (todo is null)
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(Mappings.ToTodo(todo)));
        }
示例#8
0
        public static IActionResult GetTodoById(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "todo/{id}")] HttpRequest req,
            [Table("todos", "TODO", "{id}", Connection = "AzureWebJobsStorage")] TodoTableEntity todoTable,
            ILogger log, string id)
        {
            log.LogInformation($"Getting todo item by {id}");

            try
            {
                if (todoTable == null)
                {
                    log.LogInformation($"item {id} not found");
                    return(new NotFoundResult());
                }
                return(new OkObjectResult(todoTable.ToTodo()));
            }
            catch (StorageException ex) when(ex.RequestInformation.HttpStatusCode == 404)
            {
                log.LogError($"Error in getting todo item {id}", ex);
                return(new BadRequestObjectResult($"Error in getting todo item {id}"));
            }
        }