Error compiling template "Designs/Swift/Paragraph/Swift_Logo.cshtml" Line 12: The type or namespace name 'Dna' could not be found (are you missing a using directive or an assembly reference?) Line 45: 'User' does not contain a definition for 'GetCurrentSelectedAccount' and no accessible extension method 'GetCurrentSelectedAccount' accepting a first argument of type 'User' could be found (are you missing a using directive or an assembly reference?)
1 // <auto-generated/> 2 #pragma warning disable 1591 3 namespace CompiledRazorTemplates.Dynamic 4 { 5 #line hidden 6 using System.Threading.Tasks; 7 using System; 8 using System.Collections.Generic; 9 using System.Linq; 10 using System.IO; 11 using Dynamicweb.Security.UserManagement; 12 using Dna.TerryBear.UserInheritance.Extensions; 13 internal class RazorEngine_6fd57e5ac79649adb780cfd8f28d4789 : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 14 { 15 #pragma warning disable 1998 16 public async override global::System.Threading.Tasks.Task ExecuteAsync() 17 { 18 WriteLiteral("\r\n"); 19 20 Dynamicweb.Frontend.LinkViewModel logoLink = Model.Item.GetLink("Link"); 21 22 if (logoLink is object) 23 { 24 logoLink.Url = logoLink.Url == "/" && Pageview.IsVisualEditorMode ? "/Default.aspx?AreaID=" + Pageview.Area.ID : logoLink.Url; 25 } 26 27 string horizontalAlign = !string.IsNullOrEmpty(Model.Item.GetRawValueString("HorizontalAlignment")) ? "justify-content-" + Model.Item.GetRawValueString("HorizontalAlignment") : string.Empty; 28 29 string contentPadding = Model.Item.GetRawValueString("ContentPadding", "px-3 py-2"); 30 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 31 contentPadding = contentPadding == "small" ? "px-3 py-2" : contentPadding; 32 contentPadding = contentPadding == "large" ? "px-4 py-3" : contentPadding; 33 34 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", string.Empty).Trim().ToLower() : string.Empty; 35 string title = Model.Item.GetString("LogoName","Swift"); 36 37 string logoImage = Model?.Item?.GetFile("Image")?.Path != null ? Model.Item.GetFile("Image").Path : string.Empty; 38 string logoWidth = !string.IsNullOrEmpty(Model.Item.GetString("LogoWidth")) ? "width: " + Model.Item.GetInt32("LogoWidth") + "px" : string.Empty; 39 logoWidth = logoWidth == "width: 0px" ? string.Empty : logoWidth; 40 41 42 /*START CUSTOM CODE*/ 43 if (Pageview.User != null) 44 { 45 var selectedAccount = Pageview.User.GetCurrentSelectedAccount(); 46 var user = selectedAccount ?? Pageview.User; 47 var overrideGroups = Model.Item.GetRawValueString("OverrideForUserGroups"); 48 var customerGroups = user.GetGroups(); 49 var overrideLogo = customerGroups.Any(customerGroup => overrideGroups.Split(",").Any(overrideGroup => customerGroup.ID.ToString().Equals(overrideGroup))); 50 var customerNumber = customerGroups.FirstOrDefault(cg => !string.IsNullOrEmpty(cg.CustomerNumber))?.CustomerNumber.Split('-')[0] ?? string.Empty; 51 var logoPath = "Files/Images/Logos/Provider Logos/" + customerNumber + ".png"; 52 var providerName = new UserService().GetUsersByCustomerNumber(customerNumber).FirstOrDefault()?.Name ?? string.Empty; 53 54 if (overrideLogo && !string.IsNullOrEmpty(providerName)) { 55 logoImage = ""; 56 title = providerName; 57 logoImage = File.Exists(Dynamicweb.Context.Current.Server.MapPath(logoPath)) ? logoPath : logoImage; 58 } 59 60 } 61 /*END CUSTOM CODE*/ 62 WriteLiteral("\r\n<figure"); 63 BeginWriteAttribute("class", " class=\"", 2663, "\"", 2746, 6); 64 WriteAttributeValue("", 2671, "m-0", 2671, 3, true); 65 WriteAttributeValue(" ", 2674, "d-flex", 2675, 7, true); 66 WriteAttributeValue(" ", 2681, horizontalAlign, 2682, 18, false); 67 WriteAttributeValue("", 2700, theme, 2700, 8, false); 68 WriteAttributeValue(" ", 2708, "item_", 2709, 6, true); 69 WriteAttributeValue("", 2714, Model.Item.SystemName.ToLower(), 2714, 32, false); 70 EndWriteAttribute(); 71 WriteLiteral(">\r\n\t<div"); 72 BeginWriteAttribute("id", " id=\"", 2755, "\"", 2769, 1); 73 WriteAttributeValue("", 2760, Model.ID, 2760, 9, false); 74 EndWriteAttribute(); 75 WriteLiteral(" class=\"user-select-none\" style=\"scroll-margin-top:var(--header-height,150px)\"></div>\r\n"); 76 if (logoLink is object) 77 { 78 WriteLiteral("\t\t"); 79 WriteLiteral("<a href=\""); 80 Write(logoLink.Url); 81 WriteLiteral("\" class=\"text-decoration-none\" aria-label=\""); 82 Write(title); 83 WriteLiteral("\">\r\n"); 84 } 85 WriteLiteral("\r\n"); 86 if (logoImage != string.Empty) 87 { 88 if (Path.GetExtension(logoImage).ToLower() == ".svg") 89 { 90 WriteLiteral("\t\t\t<div class=\"icon-auto\""); 91 BeginWriteAttribute("style", " style=\"", 3098, "\"", 3116, 1); 92 WriteAttributeValue("", 3106, logoWidth, 3106, 10, false); 93 EndWriteAttribute(); 94 WriteLiteral(">\r\n\t\t\t\t"); 95 Write(ReadFile(logoImage)); 96 WriteLiteral("\r\n\t\t\t</div>\r\n"); 97 } 98 else { 99 WriteLiteral("\t\t\t<picture class=\"mx-auto d-block\">\r\n\t\t\t\t<img"); 100 BeginWriteAttribute("src", " src=\"", 3218, "\"", 3234, 1); 101 WriteAttributeValue("", 3224, logoImage, 3224, 10, false); 102 EndWriteAttribute(); 103 BeginWriteAttribute("alt", " alt=\"", 3235, "\"", 3247, 1); 104 WriteAttributeValue("", 3241, title, 3241, 6, false); 105 EndWriteAttribute(); 106 BeginWriteAttribute("style", " style=\"", 3248, "\"", 3266, 1); 107 WriteAttributeValue("", 3256, logoWidth, 3256, 10, false); 108 EndWriteAttribute(); 109 WriteLiteral(">\r\n\t\t\t</picture>\r\n"); 110 } 111 } 112 else 113 { 114 WriteLiteral("\t\t<span class=\"fs-4\">"); 115 Write(title); 116 WriteLiteral("</span>\r\n"); 117 } 118 WriteLiteral("\r\n"); 119 if (logoLink is object) 120 { 121 WriteLiteral("\t\t"); 122 WriteLiteral("</a>\r\n"); 123 } 124 WriteLiteral("</figure>\r\n\r\n"); 125 } 126 #pragma warning restore 1998 127 } 128 } 129 #pragma warning restore 1591 130
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.IO 3 @using Dynamicweb.Security.UserManagement 4 @*START CUSTOM CODE*@ 5 @using Dna.TerryBear.UserInheritance.Extensions 6 @*END CUSTOM CODE*@ 7 8 @{ 9 Dynamicweb.Frontend.LinkViewModel logoLink = Model.Item.GetLink("Link"); 10 11 if (logoLink is object) 12 { 13 logoLink.Url = logoLink.Url == "/" && Pageview.IsVisualEditorMode ? "/Default.aspx?AreaID=" + Pageview.Area.ID : logoLink.Url; 14 } 15 16 string horizontalAlign = !string.IsNullOrEmpty(Model.Item.GetRawValueString("HorizontalAlignment")) ? "justify-content-" + Model.Item.GetRawValueString("HorizontalAlignment") : string.Empty; 17 18 string contentPadding = Model.Item.GetRawValueString("ContentPadding", "px-3 py-2"); 19 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 20 contentPadding = contentPadding == "small" ? "px-3 py-2" : contentPadding; 21 contentPadding = contentPadding == "large" ? "px-4 py-3" : contentPadding; 22 23 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", string.Empty).Trim().ToLower() : string.Empty; 24 string title = Model.Item.GetString("LogoName","Swift"); 25 26 string logoImage = Model?.Item?.GetFile("Image")?.Path != null ? Model.Item.GetFile("Image").Path : string.Empty; 27 string logoWidth = !string.IsNullOrEmpty(Model.Item.GetString("LogoWidth")) ? "width: " + Model.Item.GetInt32("LogoWidth") + "px" : string.Empty; 28 logoWidth = logoWidth == "width: 0px" ? string.Empty : logoWidth; 29 30 31 /*START CUSTOM CODE*/ 32 if (Pageview.User != null) 33 { 34 var selectedAccount = Pageview.User.GetCurrentSelectedAccount(); 35 var user = selectedAccount ?? Pageview.User; 36 var overrideGroups = Model.Item.GetRawValueString("OverrideForUserGroups"); 37 var customerGroups = user.GetGroups(); 38 var overrideLogo = customerGroups.Any(customerGroup => overrideGroups.Split(",").Any(overrideGroup => customerGroup.ID.ToString().Equals(overrideGroup))); 39 var customerNumber = customerGroups.FirstOrDefault(cg => !string.IsNullOrEmpty(cg.CustomerNumber))?.CustomerNumber.Split('-')[0] ?? string.Empty; 40 var logoPath = "Files/Images/Logos/Provider Logos/" + customerNumber + ".png"; 41 var providerName = new UserService().GetUsersByCustomerNumber(customerNumber).FirstOrDefault()?.Name ?? string.Empty; 42 43 if (overrideLogo && !string.IsNullOrEmpty(providerName)) { 44 logoImage = ""; 45 title = providerName; 46 logoImage = File.Exists(Dynamicweb.Context.Current.Server.MapPath(logoPath)) ? logoPath : logoImage; 47 } 48 49 } 50 /*END CUSTOM CODE*/ 51 } 52 53 <figure class="m-0 d-flex @(horizontalAlign)@(theme) item_@Model.Item.SystemName.ToLower()"> 54 <div id="@Model.ID" class="user-select-none" style="scroll-margin-top:var(--header-height,150px)"></div> 55 @if (logoLink is object) 56 { 57 @:<a href="@logoLink.Url" class="text-decoration-none" aria-label="@title"> 58 } 59 60 @if (logoImage != string.Empty) 61 { 62 if (Path.GetExtension(logoImage).ToLower() == ".svg") 63 { 64 <div class="icon-auto" style="@logoWidth"> 65 @ReadFile(logoImage) 66 </div> 67 } 68 else { 69 <picture class="mx-auto d-block"> 70 <img src="@logoImage" alt="@title" style="@logoWidth"> 71 </picture> 72 } 73 } 74 else 75 { 76 <span class="fs-4">@title</span> 77 } 78 79 @if (logoLink is object) 80 { 81 @:</a> 82 } 83 </figure> 84 85