public async Task AddAsync(long productId, ProductInfoHistory history) { history.Id = DateTime.Now.Ticks; history.RowKey = history.Id.ToString(); history.PartitionKey = productId.ToString(); await _repository.Insert(history); }
public static async void Run( [QueueTrigger(QueueName.AddProductHistory, Connection = CommonName.Connection)] ProductInfo productInfo, [Table(TableName.ProductInfoHistory)] CloudTable productInfoHistoryTable, ILogger log) { log.LogInformation($"C# Queue trigger function for history record for product : {productInfo.Name}"); if (productInfo != null) { ProductInfoHistory historyRecord = new ProductInfoHistory(); historyRecord.Id = DateTime.Now.Ticks; historyRecord.RowKey = historyRecord.Id.ToString(); historyRecord.PartitionKey = productInfo.Id.ToString(); historyRecord.Price = productInfo.Price; historyRecord.ProductInfoId = productInfo.Id; TableOperation operation = TableOperation.Insert(historyRecord); await productInfoHistoryTable.ExecuteAsync(operation); } }