Error executing template "Designs/exhibition_site/eCom/Product/MCH365-profile.cshtml"
System.Exception: Product is not of type Co3.MCH.Website.Frontend.Models.Frontend.MCH365.Profile. Check asset type of product id : TSP9341bfe2ad57a3a13ad526b944b.
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_2031e482a5d846308b5234bb395e7bc4.Execute() in E:\dynamicweb.net\Solutions\mch365.espresso5.dk\Files\Templates\Designs\exhibition_site\eCom\Product\MCH365-profile.cshtml:line 13
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.Base.Extensions 4 @using Co3.Espresso.Website.Services 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 12 @{ 13 ProfileProduct espressoProduct = Co3.MCH.Website.Frontend.Services.Ecommerce.ProductService.Instance.GetEspressoProduct( 14 new ProductSettings() 15 { 16 Id = GetString("Ecom:Product.ID"), 17 VariantId = GetString("Ecom:Product.VariantID"), 18 PrimaryVariantId = GetString("Ecom:Product.DefaultVariantComboID"), 19 EmbeddedInModelList = false 20 }, nameof(ProfileProduct) 21 ) as ProfileProduct; 22 23 // EXAMPLE 24 bool hasPresentation = espressoProduct.HasPresentation; 25 int presentationContactPersons = 0; 26 if (hasPresentation) 27 { 28 presentationContactPersons = espressoProduct.Presentation.ContactPersons.Products.Count(); 29 } 30 31 // CUSTOM COMPANY FIELDS 32 string companyDescriptionFormatted = espressoProduct.Company.DescriptionFormatted; 33 34 string companyDescriptionFormattedStrippedHtml = companyDescriptionFormatted.StripHtml(); 35 36 string companyDescriptionFormattedMetaDesc = !string.IsNullOrEmpty(companyDescriptionFormattedStrippedHtml) ? companyDescriptionFormattedStrippedHtml : espressoProduct.Company.Name; 37 38 if ( companyDescriptionFormattedStrippedHtml.Length > 160 ) 39 { 40 companyDescriptionFormattedMetaDesc = !string.IsNullOrEmpty(companyDescriptionFormattedStrippedHtml) ? companyDescriptionFormattedStrippedHtml.Substring(0, 160) : espressoProduct.Company.Name; 41 } 42 43 string companyColor = ""; 44 45 if (espressoProduct.Company.BrandColor.IsNullOrEmpty()) 46 { 47 companyColor = MCH365Context.Current.TradeShowDetails.PrimaryColor; 48 } 49 else 50 { 51 companyColor = espressoProduct.Company.BrandColor; 52 } 53 54 // CUSTOM COMPANY COLOR SCHEME 55 Regex hexcodeRegex = new Regex(@"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"); 56 companyColor = hexcodeRegex.IsMatch( companyColor ) ? companyColor : "#000000"; 57 ColorHelper.HSL brandExhibitor = ColorHelper.Instance.HexToHsl(companyColor); 58 59 // VIDEO 60 string presentationVideo = ""; 61 62 if (espressoProduct.Presentation != null && espressoProduct.Presentation.Video != null && !string.IsNullOrEmpty(espressoProduct.Presentation.Video)) 63 { 64 string presentationVideoRaw = espressoProduct.Presentation.Video; 65 66 if (presentationVideoRaw.Contains("https://vimeo.com/")) 67 { 68 presentationVideo = "https://player.vimeo.com/video/" + (presentationVideoRaw.Replace("https://vimeo.com/", "")); 69 } 70 else if (presentationVideoRaw.Contains("https://youtu")) 71 { 72 presentationVideo = ("https://www.youtube.com/embed/" + presentationVideoRaw.Replace("https://youtu.be/", "").Replace("https://www.youtube.com/embed/", "")); 73 } 74 else if (presentationVideoRaw.Contains("https://www.youtube.com/watch?v=")) 75 { 76 presentationVideo = ("https://www.youtube.com/embed/" + presentationVideoRaw.Replace("https://www.youtube.com/watch?v=", "")); 77 } 78 else 79 { 80 presentationVideo = ("https://www.youtube.com/embed/" + presentationVideoRaw); 81 } 82 } 83 } 84 85 <style> 86 :root { 87 --exhibitor-color: @brandExhibitor.ToString(); 88 --exhibitor-color-darken: @brandExhibitor.Darken(10).ToString(); 89 --exhibition-profile-exhibitor-brand-color: hsl(var(--exhibitor-color)); 90 --exhibition-profile-exhibitor-brand-color-darken: hsl(var(--exhibitor-color-darken)); 91 --exhibition-profile-exhibitor-brand-color-opaque: hsla(var(--exhibitor-color), 0.85); 92 } 93 94 .breadcrumb.nav { 95 background-color: var(--exhibition-profile-exhibitor-brand-color-darken); 96 } 97 98 </style> 99100 @RenderingService.Instance.SectionEnd() 101 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-topsection.cshtml", espressoProduct) 102 @RenderingService.Instance.SectionStart(new SectionSettings 103 { 104 Classes = new ClassList("e-section mch365-custom-product-details-wrapper") 105 }) 106107108 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-sidebar.cshtml", espressoProduct) 109 <div class="col-12 col-md-8 col-lg-9 p-columns mch365-custom-product-details-wrapper-main-content"> 110 <div class="row mt-2 mt-md-4"> 111 <div class="col-12"> 112 <div class="row"> 113 <div class="col-12 col-lg-8 mb-2 pr-lg-2 pr-xl-3" id="presentation"> 114115116 @if( !string.IsNullOrEmpty(companyDescriptionFormatted)) { 117 <p>@companyDescriptionFormatted</p> 118 } 119 else 120 { 121 <h4>@Translate("MCH365 - Exhibitor details descriptionNoInfoHeader - Heading", "Vi har registreret udstilleren som leverandør eller udstiller på messen.")</h4> 122 <p>@Translate("MCH365 - Exhibitor details descriptionNoInfoText - Text", "Dog har de endnu ikke oplyst yderligere beskrivelse på deres profil.")</p> 123 } 124125126 </div> 127 @if (espressoProduct.ContactPersons.Products.Any()) 128 { 129 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-contactpersons.cshtml", espressoProduct) 130 } 131 </div> 132133 @if (espressoProduct.Products.Products.Any()) 134 { 135 <div class="row"> 136 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-products.cshtml", espressoProduct) 137 </div> 138 } 139 @if (espressoProduct.Articles.Products.Any()) 140 { 141 <div class="row"> 142 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-articles.cshtml", espressoProduct) 143 </div> 144 } 145 @if (espressoProduct.Cases.Products.Any()) 146 { 147 <div class="row"> 148 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-cases.cshtml", espressoProduct) 149 </div> 150 } 151 @if (espressoProduct.Events.Products.Any()) 152 { 153 <div class="row"> 154 @RenderingService.Instance.PartialView("ecom/product/partials/profile-details/MCH365-events.cshtml", espressoProduct) 155 </div> 156 } 157158 </div> 159 </div> 160 </div> 161 @RenderingService.Instance.SectionEnd() 162 @RenderingService.Instance.SectionStart(new SectionSettings()) 163164 @SnippetStart("profileProductCompanyDescription")@companyDescriptionFormattedMetaDesc@SnippetEnd("profileProductCompanyDescription") @* Avoid using linebreaks in this snippet, as it will also add linebreaks to the content *@
keyboard_arrow_up