public static FlowerTableStorage ToFlowerTableStorage(this In_FlowerDto flower) { return(new FlowerTableStorage { PartitionKey = "Flower", RowKey = flower.Id, Name = flower.Name, Description = flower.Description, Price = flower.Price, Timestamp = flower.CreationDate, IsActive = flower.IsActive }); }
public static async Task <IActionResult> CreateFlowerTableStorage( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "flowerTS")] HttpRequest req, [Table("Flower", Connection = "AzureWebJobsStorage")] IAsyncCollector <FlowerTableStorage> flowerTable, ILogger log) { log.LogInformation("Create TableStorage flower method"); var reqBody = await new StreamReader(req.Body).ReadToEndAsync(); var flowerViewModel = JsonConvert.DeserializeObject <FlowerCreateViewModel>(reqBody); var flower = new In_FlowerDto { Name = flowerViewModel.Name, Description = flowerViewModel.Description, Price = flowerViewModel.Price, IsActive = flowerViewModel.IsActive }; await flowerTable.AddAsync(flower.ToFlowerTableStorage()); return(new OkObjectResult(flowerViewModel)); }