public async Task CreateOrderFromBasket(OrderCreationRequest creationRequest) { using (var t = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { // Transform the basket into an order var orderingId = await sqlDataAccess.CreateOrderFromBasket(creationRequest); if (creationRequest.BestellerId != creationRequest.CurrentUserId) { await sqlDataAccess.ChangeUserForOrdering(orderingId, creationRequest.BestellerId); } // get the order items of the order var order = await sqlDataAccess.GetOrdering(orderingId); if (creationRequest.FunktionDigitalisierungAusloesen) { // Digitalisierungs-Kategorie Gesuch setzen await sqlDataAccess.UpdateDigipool(order.Items.Select(i => i.Id).ToList(), (int)DigitalisierungsKategorie.Gesuch, null); foreach (var orderItem in order.Items) { orderItem.DigitalisierungsKategorie = DigitalisierungsKategorie.Gesuch; } } // Execute state change await statusWechsler.Execute(oi => oi.Bestellen(), order.Items, GetUser(creationRequest.CurrentUserId), DateTime.Now); // If we are here, we can commit all pending updates t.Complete(); } }