private async Task <List <ImportMovement> > CaptureAddedImportMovements(CancelImportMovements message) { var result = new List <ImportMovement>(); foreach (var addedMovement in message.AddedMovements) { var movement = await importMovementFactory.Create(message.NotificationId, addedMovement.Number, addedMovement.ShipmentDate, null); movementRepository.Add(movement); await context.SaveChangesAsync(); result.Add(movement); } foreach (var movement in result) { await movementAuditRepository.Add(new ImportMovementAudit(movement.NotificationId, movement.Number, userContext.UserId.ToString(), (int)MovementAuditType.NoPrenotificationReceived, SystemTime.Now)); } await context.SaveChangesAsync(); return(result); }
public async Task <Guid> HandleAsync(CreateImportMovement message) { var movement = await importMovementFactory.Create(message.NotificationId, message.Number, message.ActualShipmentDate, message.PrenotificationDate); if (message.PrenotificationDate.HasValue) { movement.SetPrenotificationDate(message.PrenotificationDate.Value); } movementRepository.Add(movement); await context.SaveChangesAsync(); return(movement.Id); }