public async Task SavePizza(PizzaModel pizzaModel) { Pizza pizzaEntity = _mapper.Map <Pizza>(pizzaModel); // Todo: Verify security checks using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) { int pizzaRows = await _pizzaRepo.AddEntityAsync(pizzaEntity); int ingredientRows = await _ingredientRepo.PutIngredientsOnPizza( pizzaModel.PizzaId, pizzaModel.Ingredients.Select(x => x.IngredientId).ToArray()); Console.WriteLine(pizzaRows); Console.WriteLine(ingredientRows); // Commit transaction if all commands succeed, transaction will auto-rollback // when disposed if either commands fails scope.Complete(); } }