Error executing template "Designs/exhibition_site/eCom/Product/MCH365-exhibitor.cshtml"
System.Exception: Product is not of type Co3.MCH.Website.Frontend.Models.Frontend.MCH365.Profile. Check asset type of product id : TSP5a2bd899e4d712d316788f79e94.
at Co3.MCH.Website.Frontend.Models.Frontend.Ecommerce.ProfileProduct.Populate(ProductSettings settings) in C:\Data\Development\git\mch-master\Co3.MCH.Website.Frontend\Models\Frontend\Ecommerce\ProfileProduct.cs:line 72
at Co3.MCH.Website.Frontend.Services.Ecommerce.ProductService.GetEspressoProduct(ProductSettings settings, String key) in C:\Data\Development\git\mch-master\Co3.MCH.Website.Frontend\Services\Ecommerce\ProductService.cs:line 46
at CompiledRazorTemplates.Dynamic.RazorEngine_70d3907009944cfd9b4319c93b5bbebc.Execute() in E:\dynamicweb.net\Solutions\mch365.espresso5.dk\Files\Templates\Designs\exhibition_site\eCom\Product\MCH365-exhibitor.cshtml:line 14
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 Co3.Espresso.Website.TemplateBases.Paragraphs.Module 2 @using System.Text.RegularExpressions 3 @using Co3.Espresso.Website.Services 4 @using Co3.Espresso.Base.Extensions 5 @using Co3.Espresso.Website.Models.FrontEnd 6 @using Co3.Espresso.Website.Models.FrontEnd.Settings 7 @using Co3.MCH.Website.Frontend.Helpers 8 @using Co3.MCH.Website.Frontend.Models.Frontend 9 @using Co3.MCH.Website.Frontend.Models.Frontend.Ecommerce 10 @using Dynamicweb.Core 11 @using Dynamicweb.Frontend 12 13 @{ 14 ProfileProduct espressoProduct = Co3.MCH.Website.Frontend.Services.Ecommerce.ProductService.Instance.GetEspressoProduct( 15 new ProductSettings() 16 { 17 Id = GetString("Ecom:Product.ID"), 18 VariantId = GetString("Ecom:Product.VariantID"), 19 PrimaryVariantId = GetString("Ecom:Product.DefaultVariantComboID"), 20 EmbeddedInModelList = false 21 }, nameof(ProfileProduct) 22 ) as ProfileProduct; 23 24 // EXAMPLE 25 bool hasPresentation = espressoProduct.HasPresentation; 26 int presentationContactPersons = 0; 27 if (hasPresentation) 28 { 29 presentationContactPersons = espressoProduct.Presentation.ContactPersons.Products.Count(); 30 } 31 32 bool hasCookiebot = PageView.Current().Area.Item[ "Cookiebot" ].ToString() == "True"; 33 34 // CUSTOM COMPANY FIELDS 35 string companyDescriptionFormatted = espressoProduct.Company.DescriptionFormatted; 36 37 string companyDescriptionFormattedStrippedHtml = companyDescriptionFormatted.StripHtml(); 38 39 string companyDescriptionFormattedMetaDesc = !string.IsNullOrEmpty(companyDescriptionFormattedStrippedHtml) ? companyDescriptionFormattedStrippedHtml : espressoProduct.Company.Name; 40 41 if ( companyDescriptionFormattedStrippedHtml.Length > 160 ) 42 { 43 companyDescriptionFormattedMetaDesc = !string.IsNullOrEmpty(companyDescriptionFormattedStrippedHtml) ? companyDescriptionFormattedStrippedHtml.Substring(0, 160) : espressoProduct.Company.Name; 44 } 45 46 string companyColor = ""; 47 48 if (espressoProduct.Company.BrandColor.IsNullOrEmpty()) 49 { 50 companyColor = MCH365Context.Current.TradeShowDetails.PrimaryColor; 51 } 52 else 53 { 54 companyColor = espressoProduct.Company.BrandColor; 55 } 56 57 // CUSTOM COMPANY COLOR SCHEME 58 Regex hexcodeRegex = new Regex(@"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"); 59 companyColor = hexcodeRegex.IsMatch( companyColor ) ? companyColor : "#000000"; 60 ColorHelper.HSL brandExhibitor = ColorHelper.Instance.HexToHsl(companyColor); 61 62 // VIDEO 63 string presentationVideo = ""; 64 65 if (espressoProduct.Presentation != null && espressoProduct.Presentation.Video != null && !string.IsNullOrEmpty(espressoProduct.Presentation.Video)) 66 { 67 string presentationVideoRaw = espressoProduct.Presentation.Video; 68 69 if (presentationVideoRaw.Contains("https://vimeo.com/")) 70 { 71 presentationVideo = "https://player.vimeo.com/video/" + (presentationVideoRaw.Replace("https://vimeo.com/", "")); 72 } 73 else if (presentationVideoRaw.Contains("https://youtu")) 74 { 75 presentationVideo = ("https://www.youtube.com/embed/" + presentationVideoRaw.Replace("https://youtu.be/", "").Replace("https://www.youtube.com/embed/", "")); 76 } 77 else if (presentationVideoRaw.Contains("https://www.youtube.com/watch?v=")) 78 { 79 presentationVideo = ("https://www.youtube.com/embed/" + presentationVideoRaw.Replace("https://www.youtube.com/watch?v=", "")); 80 } 81 else 82 { 83 presentationVideo = ("https://www.youtube.com/embed/" + presentationVideoRaw); 84 } 85 } 86 } 87 88 <style> 89 :root { 90 --exhibitor-color: @brandExhibitor.ToString(); 91 --exhibitor-color-darken: @brandExhibitor.Darken(10).ToString(); 92 --exhibition-profile-exhibitor-brand-color: hsl(var(--exhibitor-color)); 93 --exhibition-profile-exhibitor-brand-color-darken: hsl(var(--exhibitor-color-darken)); 94 --exhibition-profile-exhibitor-brand-color-opaque: hsla(var(--exhibitor-color), 0.85); 95 } 96 97 .breadcrumb.nav { 98 background-color: var(--exhibition-profile-exhibitor-brand-color-darken); 99 } 100101 </style> 102103 @RenderingService.Instance.SectionEnd() 104 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-topsection.cshtml", espressoProduct) 105 @RenderingService.Instance.SectionStart(new SectionSettings 106 { 107 Classes = new ClassList("e-section mch365-custom-product-details-wrapper") 108 }) 109 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-sidebar.cshtml", espressoProduct) 110 <div class="col-12 col-md-8 col-lg-9 p-columns mch365-custom-product-details-wrapper-main-content"> 111 <div class="row mt-2 mt-md-4"> 112 <div class="col-12"> 113 <div class="row"> 114 <div class="col-12 col-lg-8 mb-2 pr-lg-2 pr-xl-3" id="presentation"> 115116 @if (hasPresentation && !string.IsNullOrEmpty(espressoProduct.Presentation.DescriptionFormatted)) 117 { 118 <p>@espressoProduct.Presentation.DescriptionFormatted</p> 119 } 120 else { 121 if( !string.IsNullOrEmpty(companyDescriptionFormatted)) { 122 <p>@companyDescriptionFormatted</p> 123 } 124 else 125 { 126 <h4>@Translate("MCH365 - Exhibitor details descriptionNoInfoHeader - Heading", "Vi har registreret udstilleren som leverandør eller udstiller på messen.")</h4> 127 <p>@Translate("MCH365 - Exhibitor details descriptionNoInfoText - Text", "Dog har de endnu ikke oplyst yderligere beskrivelse på deres profil.")</p> 128 } 129 } 130131 @if (hasPresentation) 132 { 133 if (!string.IsNullOrEmpty(presentationVideo)) 134 { 135 <div class="video-container mt-5 mb-4"> 136 @if ( hasCookiebot ) { 137 <div class="cookieconsent-optout-marketing "> 138 <a href="javascript:Cookiebot.renew()" class="btn"> 139 <small>@Translate("Cookies - Accept to watch", "Accepter marketing-cookies for at se denne video.")</small> 140 <br/> 141 <i class="material-icons">play_arrow</i> 142 </a> 143 </div> 144 <iframe data-cookieconsent="marketing" class="responsive-iframe" data-src="@presentationVideo" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe> 145 } 146 else 147 { 148 <iframe class="responsive-iframe" src="@presentationVideo" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe> 149 } 150 </div> 151 } 152 } 153 </div> 154 @if (espressoProduct.ContactPersons.Products.Any()) 155 { 156 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-contactpersons.cshtml", espressoProduct) 157 } 158 </div> 159160 @if (espressoProduct.Products.Products.Any()) 161 { 162 <div class="row"> 163 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-products.cshtml", espressoProduct) 164 </div> 165 } 166 @if (espressoProduct.Articles.Products.Any()) 167 { 168 <div class="row"> 169 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-articles.cshtml", espressoProduct) 170 </div> 171 } 172 @if (espressoProduct.Cases.Products.Any()) 173 { 174 <div class="row"> 175 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-cases.cshtml", espressoProduct) 176 </div> 177 } 178179180 @if (espressoProduct.Events.Products.Any()) 181 { 182 <div class="row"> 183 @RenderingService.Instance.PartialView("ecom/product/partials/exhibitor-details/MCH365-events.cshtml", espressoProduct) 184 </div> 185 } 186 </div> 187 </div> 188 </div> 189 @RenderingService.Instance.SectionEnd() 190 @RenderingService.Instance.SectionStart(new SectionSettings()) 191192 @SnippetStart("profileProductCompanyDescription")@companyDescriptionFormattedMetaDesc@SnippetEnd("profileProductCompanyDescription") @* Avoid using linebreaks in this snippet, as it will also add linebreaks to the content *@
keyboard_arrow_up