Error executing template "/Designs/Swift/Paragraph/Swift_ProductPrice_Mennt.cshtml"
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at Dynamicweb.Ecommerce.Prices.PriceManager.GetPrice(PriceContext context, Product product, String unitId, Int64 stockLocationId)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_2.<BulkCreateView>b__48()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetPrice(PriceViewModelSettings settings, IList`1 products, Boolean& pricesHasBeenPrepared, Object lock, Lazy`1 priceInfo)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass3_2.<BulkCreateView>b__49()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_5a7e726e3ba2410b8b0413e7edbeb627.Execute() in D:\dynamicweb.net\Solutions\Mennt\KunstWeb2023.dw9.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductPrice_Mennt.cshtml:line 86
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
  1     @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
  2     @using Dynamicweb.Ecommerce.ProductCatalog
  3     
  4     @{
  5     	ProductViewModel product = null;
  6     	if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
  7     	{
  8     		product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
  9     	}
 10     	else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode)
 11     	{
 12     		var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page);
 13     		ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel();
 14     
 15     		if (productList?.Products is object)
 16     		{
 17     			product = productList.Products[0];
 18     		}
 19     	}
 20     
 21     	string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", "");
 22     	bool anonymousUser = Pageview.User == null;
 23     	bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]);
 24     	bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown;
 25     	
 26     	bool productIsDiscontinued = product is object  && product.Discontinued;
 27     	bool doNotShowPriceIfProductIsDiscontinued = Model.Item.GetBoolean("DoNotShowPriceIfProductIsDiscontinued");
 28     	var isDiscontinued = productIsDiscontinued && doNotShowPriceIfProductIsDiscontinued;
 29     }
 30     
 31     @if (product is object && !hidePrice && !isDiscontinued) {
 32     	bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice");
 33     	string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty;
 34     
 35     	string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2");
 36     	string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", "");
 37     	string layout = Model.Item.GetRawValueString("Layout", "horizontal");
 38     	string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty;
 39     	textAlign = horizontalAlign == "end" ? "text-end" : textAlign;
 40     
 41     	horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign;
 42     	horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign;
 43     	horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign;
 44     	horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign;
 45     
 46     	string flexDirection = layout == "horizontal" ? string.Empty : "flex-column";
 47     	string flexGap = layout == "horizontal" ? "gap-3" : string.Empty;
 48     	string order = layout == "horizontal" ? string.Empty : "order-2";
 49     	string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
 50     	theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme;
 51     
 52     	string contentPadding = Model.Item.GetRawValueString("ContentPadding", "");
 53     	contentPadding = contentPadding == "none" ? "p-0" : contentPadding;
 54     	contentPadding = contentPadding == "small" ? "p-1 px-md-2 py-md-1" : contentPadding;
 55     	contentPadding = contentPadding == "large" ? "p-2 px-md-3 py-md-2" : contentPadding;
 56     
 57     	string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower();
 58     	bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat);
 59     
 60     	string priceMin = "";
 61     	string priceMax = "";
 62     
 63     	string liveInfoClass = "";
 64     	string productInfoFeed = "";
 65     	bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]);
 66     	if (isLazyLoadingForProductInfoEnabled)
 67     	{
 68     		if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed"))
 69     		{
 70     			productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString();
 71     			if (!string.IsNullOrEmpty(productInfoFeed))
 72     			{
 73     				productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\"";
 74     			}
 75     		}
 76     		liveInfoClass = "js-live-info";
 77     	}
 78     
 79     	<div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" data-variant-id="@product.VariantId" @productInfoFeed>
 80     		@if (showInformativePrice && product.PriceInformative.Price != 0)
 81     		{
 82     			<div class="opacity-50">
 83     				<span>@Translate("RRP") </span>
 84     				<span class="text-decoration-line-through text-price">@product.PriceInformative.PriceFormatted</span>
 85     			</div>
 86     		}
 87     		<div class="@priceFontSize m-0 d-flex flex-wrap @flexDirection @flexGap @horizontalAlign" style="row-gap: 0 !important" itemprop="offers" itemscope itemtype="https://schema.org/Offer">
 88     			<span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span>
 89     
 90     
 91     			@if (showPricesWithVat == "false" && !neverShowVat)
 92     			{
 93     				if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode)
 94     				{
 95     					<span itemprop="price" content="" class="d-none"></span>
 96     					<span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span>
 97     				}
 98     				else
 99     				{
100     					string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceWithoutVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted;
101     
102     					<span itemprop="price" content="@product.Price.PriceWithoutVat" class="d-none"></span>
103     					if (product.Price.Price != product.PriceBeforeDiscount.Price)
104     					{
105     						<span class="text-decoration-line-through opacity-75 @order">@beforePrice</span>
106     					}
107     				}
108     			}
109     			else
110     			{
111     				if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode)
112     				{
113     					<span itemprop="price" content="" class="d-none"></span>
114     					<span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span>
115     				}
116     				else
117     				{
118     					string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product.PriceBeforeDiscount.PriceFormatted;
119     
120     					<span itemprop="price" content="@product.Price.Price" class="d-none"></span>
121     
122     					if (product.Price.Price != product.PriceBeforeDiscount.Price)
123     					{
124     						<span class="text-decoration-line-through opacity-75 @order">
125     							<span class="text-price">@beforePrice</span>
126     						</span>
127     					}
128     				}
129     			}
130     
131     			@if (showPricesWithVat == "false" && !neverShowVat)
132     			{
133     				if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode)
134     				{
135     					<span class="text-price js-text-price">
136     						<span class="spinner-border" role="status"></span>
137     					</span>
138     				}
139     				else
140     				{
141     					string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithoutVatFormatted : product.Price.PriceWithoutVatFormatted;
142     
143     					if (product?.VariantInfo?.VariantInfo != null)
144     					{
145     						priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : "";
146     						priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : "";
147     					}
148     					if (priceMin != priceMax)
149     					{
150     						price = priceMin + " - " + priceMax;
151     					}
152     					<span class="@theme @contentPadding">
153     						<span class="text-price">@price</span>
154     					</span>
155     				}
156     			}
157     			else
158     			{
159     				if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode)
160     				{
161     					<span class="text-price js-text-price">
162     						<span class="spinner-border" role="status"></span>
163     					</span>
164     				}
165     				else
166     				{
167     					string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product.Price.PriceFormatted;
168     
169     					if (product?.VariantInfo?.VariantInfo != null)
170     					{
171     						priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : "";
172     						priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : "";
173     					}
174     					if (priceMin != priceMax)
175     					{
176     						price = priceMin + " - " + priceMax;
177     					}
178     					<span class="@theme @contentPadding">
179     						<span class="text-price">@price.Replace(",00", "")</span>
180     					</span>
181     				}
182     			}
183     
184     			@* Stock state for Schema.org, start *@
185     			@{
186     				Uri url = Dynamicweb.Context.Current.Request.Url;
187     			}
188     
189     			<link itemprop="url" href="@url">
190     
191     			@{
192     				bool IsNeverOutOfStock = product.NeverOutOfstock;
193     			}
194     
195     			@if (IsNeverOutOfStock)
196     			{
197     				<span itemprop="availability" class="d-none">@Translate("Available in stock")</span>
198     			}
199     			else
200     			{
201     				if (product.StockLevel > 0)
202     				{
203     					<span itemprop="availability" class="d-none">InStock</span>
204     				}
205     				else
206     				{
207     					<span itemprop="availability" class="d-none">OutOfStock</span>
208     				}
209     			}
210     			@* Stock state for Schema.org, stop *@
211     
212     		</div>
213     
214     		@if (showPricesWithVat == "false" && !neverShowVat)
215     		{
216     			if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode)
217     			{
218     				<small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate("Incl. VAT")"></small>
219     			}
220     			else
221     			{
222     				string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithVatFormatted : product.Price.PriceWithVatFormatted;
223     
224     				if (product?.VariantInfo?.VariantInfo != null)
225     				{
226     					priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : "";
227     					priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : "";
228     				}
229     				if (priceMin != priceMax)
230     				{
231     					price = priceMin + " - " + priceMax;
232     				}
233     				<small class="opacity-85 fst-normal">@price @Translate("Incl. VAT")</small>
234     			}
235     		}
236     	</div>
237     }
238     else if (Pageview.IsVisualEditorMode)
239     {
240     	<div class="alert alert-dark m-0" role="alert">
241     		<span>@Translate("No products available")</span>
242     	</div>
243     }
244