Rita bikini-bh med protesficka Marinblå
Damella
499 kr
InStock
Error executing template "Designs/Swift/Paragraph/Swift_ProductDefaultImage.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_0061334be6f9425c92e3f9a7b302ea35.<>c__DisplayClass0_0.<ExecuteAsync>b__2(MediaViewModel x) at System.Collections.Generic.List`1.RemoveAll(Predicate`1 match) at CompiledRazorTemplates.Dynamic.RazorEngine_0061334be6f9425c92e3f9a7b302ea35.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) 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 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 ProductViewModel product = null; 7 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 8 { 9 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 10 } 11 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 12 { 13 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 14 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 15 16 if (productList?.Products is object) 17 { 18 product = productList.Products[0]; 19 } 20 } 21 } 22 23 @if (product is object) 24 { 25 string imagePath = product?.DefaultImage?.Value ?? ""; 26 string imagePathUrlEncoded = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 27 28 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 29 ratio = ratio != "0" ? ratio : ""; 30 string ratioCssClass = ratio != "" ? " ratio" : ""; 31 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio + ";" : ""; 32 33 string width = Model.Item.GetRawValueString("Width", "auto"); 34 int smallImageSize = 640; 35 int largeImageSize = width == "auto" ? 1280 : Convert.ToInt32(width); 36 37 string ImageObjectFit = Model.Item.GetRawValueString("ImageObjectFit", "contain"); 38 39 string imagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + imagePathUrlEncoded + "&format=webp"; 40 string imagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePathUrlEncoded + "&format=webp"; 41 string imagePathFallBack = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePathUrlEncoded + "&format=webp"; 42 43 var badgeParms = new Dictionary<string, object>(); 44 badgeParms.Add("size", "h7"); 45 badgeParms.Add("saleBadgeType", Model.Item.GetRawValue("SaleBadgeType")); 46 badgeParms.Add("saleBadgeCssClassName", Model.Item.GetRawValue("SaleBadgeDesign")); 47 badgeParms.Add("newBadgeCssClassName", Model.Item.GetRawValue("NewBadgeDesign")); 48 badgeParms.Add("newPublicationDays", Model.Item.GetInt32("NewPublicationDays")); 49 badgeParms.Add("campaignBadgesValues", Model.Item.GetList("CampaignBadges")?.GetRawValue().OfType<string>().ToList()); 50 51 string badgeSize = Model.Item.GetRawValueString("BadgeSize", "fs-2"); 52 53 bool showFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 54 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 55 bool anonymousUser = Pageview.User == null; 56 57 var favoriteParameters = new Dictionary<string, object>(); 58 if (!anonymousUser && showFavoritesSelector) 59 { 60 int defaultFavoriteListId = 0; 61 62 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 63 if (favoreiteLists.Count() == 1) 64 { 65 foreach (FavoriteList list in favoreiteLists) 66 { 67 defaultFavoriteListId = list.ListId; 68 } 69 } 70 71 favoriteParameters.Add("ListId", defaultFavoriteListId); 72 } 73 74 MediaViewModel alternativeImage = new MediaViewModel(); 75 if (Model.Item.GetBoolean("ShowAlternativeImageOnHover")) { 76 var selectedImageCategories = Model.Item.GetList("GetAlternativeImageFrom")?.GetRawValue().OfType<string>().ToList(); 77 List<MediaViewModel> allAssetsImages = product.AssetCategories.Where(x => selectedImageCategories.Contains(x.SystemName)).SelectMany(x => x.Assets).ToList(); 78 allAssetsImages.RemoveAll(x => x.Value == product.DefaultImage.Value); 79 alternativeImage = allAssetsImages.FirstOrDefault(); 80 } 81 82 string altImagePathXs = string.Empty; 83 string altImagePathS = string.Empty; 84 85 if (!string.IsNullOrEmpty(alternativeImage?.Value)) 86 { 87 altImagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + Dynamicweb.Context.Current.Server.UrlEncode(alternativeImage.Value) + "&format=webp"; 88 altImagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + Dynamicweb.Context.Current.Server.UrlEncode(alternativeImage.Value) + "&format=webp"; 89 } 90 91 @* Theme settings *@ 92 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 93 string themeBorder = !string.IsNullOrWhiteSpace(theme) ? "border: 1px solid rgba(0,0,0,0)" : ""; 94 string themePadding = !string.IsNullOrWhiteSpace(theme) ? "p-2 p-lg-3" : ""; 95 96 string imageId = "ProductImage_" + product.Id + product.VariantId.Replace(".", "_"); 97 98 bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("SaleBadgeDesign")) && Model.Item.GetRawValueString("SaleBadgeDesign") != "none" ? true : false; 99 bool newBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("NewBadgeDesign")) && Model.Item.GetRawValueString("NewBadgeDesign") != "none" ? true : false; 100 DateTime createdDate = product.Created.Value; 101 bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; 102 showBadges = (newBadgeEnabled && Model.Item.GetInt32("NewPublicationDays") == 0) || (newBadgeEnabled && (createdDate.AddDays(Model.Item.GetInt32("NewPublicationDays")) > DateTime.Now)) ? true : showBadges; 103 showBadges = !string.IsNullOrEmpty(Model.Item.GetRawValueString("CampaignBadges")) ? true : showBadges; 104 105 string fullWidth = width == "auto" ? "w-100" : ""; 106 // string customWidth = width != "auto" ? "style=\"width: " + width + "px\"" : "style=\"min-width: 60px\""; 107 string customWidth = width != "auto" ? "style=\"width: " + width + "px\"" : ""; 108 109 string altImageZindex = Model.Item.GetBoolean("ShowAlternativeImageOnHover") && !string.IsNullOrEmpty(alternativeImage?.Value) ? " z-index: 1" : string.Empty; 110 111 if (!string.IsNullOrEmpty(imagePath)) 112 { 113 <div class="h-100 @fullWidth @theme position-relative item_@Model.Item.SystemName.ToLower()" @customWidth> 114 <div class="ratio" style="@(ratioVariable)"> 115 <div class="d-flex justify-content-center align-items-center"> 116 @if (imagePath.StartsWith("/Files/", StringComparison.OrdinalIgnoreCase)) 117 { 118 <img id="@imageId" 119 srcset=" 120 @imagePathXs @(smallImageSize)w, 121 @imagePathS @(largeImageSize)w" 122 sizes="(max-width: 992px) 50vw, 25vw" 123 src="@imagePathFallBack" 124 @if (Model.Item.GetBoolean("ShowAlternativeImageOnHover") && !string.IsNullOrEmpty(alternativeImage?.Value)) { <text> 125 data-alternative-image=" 126 @altImagePathXs @(smallImageSize)w, 127 @altImagePathS @(largeImageSize)w" 128 onmouseover="swift.Image.swapImage(event)" 129 onmouseout="swift.Image.swapImage(event)" 130 </text> } 131 loading="lazy" 132 decoding="async" 133 class="h-100 w-100 @themePadding" 134 style="object-fit: @ImageObjectFit; @themeBorder" 135 alt="@product.Name" 136 itemprop="image"> 137 } 138 else 139 { 140 <img src="@product.DefaultImage.Value" 141 loading="lazy" 142 class="h-100 w-100 @themePadding" 143 style="object-fit: contain; @themeBorder" 144 alt="@product.Name" 145 itemprop="image"> 146 } 147 </div> 148 </div> 149 150 @if (showBadges) 151 { 152 <div class="position-absolute top-0 left-0 @badgeSize" style="z-index: 2"> 153 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 154 </div> 155 } 156 157 @if (!anonymousUser) 158 { 159 if (showFavoritesSelector) 160 { 161 <div class="position-absolute top-0 end-0 my-3" style="z-index: 2"> 162 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 163 </div> 164 } 165 } 166 </div> 167 } 168 } 169 else if (Pageview.IsVisualEditorMode) 170 { 171 <div class="alert alert-dark m-0">@Translate("No products available")</div> 172 } 173