public static async Task MakeCreditOperationExpired( [ActivityTrigger] CreditOperation operation, [Table(nameof(CreditOperation))] CloudTable table, [Queue(Global.QUEUE)] IAsyncCollector <string> console, ILogger logger ) { logger.LogInformation("Expiring credit operation: {operation}", operation.Identifier); var queryResult = await table.ExecuteAsync(TableOperation.Retrieve <CreditOperation>(operation.PartitionKey, operation.RowKey)); var creditOperation = (CreditOperation)queryResult.Result; if (creditOperation == null) { throw new Exception($"Credit Operation: {operation.Identifier} not found!"); } creditOperation.Expire(); await table.ExecuteAsync(TableOperation.Replace(creditOperation)); await console.AddAsync($"Credit operation: {operation.Identifier} expired"); logger.LogInformation("Credit operation: {operation} expired!", operation.Identifier); }
public void InsertOrUpdate(CreditOperation creditoperation) { if (creditoperation.Id == default(int)) { // New entity context.CreditOperations.Add(creditoperation); } else { // Existing entity context.Entry(creditoperation).State = EntityState.Modified; } }
public void UpdateAccountOperation(Order order) { CreditOperation operation = context.CreditOperations.SingleOrDefault(o => o.Order.Id == order.Id); if (operation == null) { operation = new CreditOperation { Order = order }; order.Person.Operations.Add(operation); } operation.Date = DateTime.Now; operation.Amount = order.OrderDetail.Sum(od => od.Product.Price * od.Quantity); order.Person.CalculateBalance(); context.Entry(order.Person).State = EntityState.Modified; }