Coronavirus

Mange services og tilbud er genåbnet helt eller delvist. Få et samlet overblik på gladsaxe.dk/corona

Skip til hoved indholdet
Error executing template "Designs/bleau-solutionset/Paragraph/Contact.cshtml"
System.IndexOutOfRangeException: There is no row at position 0.
   at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
   at System.Data.DataRowCollection.get_Item(Int32 index)
   at DisPlay.DW.Models.ContactPerson..ctor(Type personType, Int32 itemId)
   at CompiledRazorTemplates.Dynamic.RazorEngine_a361ce70b596434abd039df8976be1f0.GetPersons(Type contactType, String personListName, String heading) in D:\Dynamicweb.Net\www.gladsaxe.dk (DW9.x)\Files\Templates\Designs\bleau-solutionset\Paragraph\Contact.cshtml:line 41
   at CompiledRazorTemplates.Dynamic.RazorEngine_a361ce70b596434abd039df8976be1f0.GetContactPersonList() in D:\Dynamicweb.Net\www.gladsaxe.dk (DW9.x)\Files\Templates\Designs\bleau-solutionset\Paragraph\Contact.cshtml:line 31
   at CompiledRazorTemplates.Dynamic.RazorEngine_a361ce70b596434abd039df8976be1f0.Execute() in D:\Dynamicweb.Net\www.gladsaxe.dk (DW9.x)\Files\Templates\Designs\bleau-solutionset\Paragraph\Contact.cshtml:line 221
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 2 3 @using System.Text 4 @using CustomModules.GeneralFunctions 5 @using DisPlay.DW.Models 6 @using Dynamicweb.Rendering; 7 @using Dynamicweb.Frontend; 8 @using DisPlay.DW.Models; @* don't delete this line, or you don't have intellisense on some classes!! *@ 9 @using TimeSpan = DisPlay.DW.Models.TimeSpan 10 11 @functions { 12 private string GetPhoneNumbers() 13 { 14 var numbers = new StringBuilder(); 15 16 foreach (var phoneNumber in GetLoop("Item.OrganizationPhoneNumberList")) 17 { 18 numbers.Append(PhoneNumber.Format(phoneNumber.GetString("Item.OrganizationPhoneNumberList.PhoneNumber"))).Append("<br />"); 19 } 20 21 return numbers.ToString(); 22 } 23 24 private string GetContactManagerList() 25 { 26 return GetPersons(ContactPerson.Type.ManagerPerson, "Item.ContactManagerList", "Ledelse"); 27 } 28 29 private string GetContactPersonList() 30 { 31 return GetPersons(ContactPerson.Type.ContactPerson, "Item.ContactPersonList", "Kontaktperson"); 32 } 33 34 private string GetPersons(ContactPerson.Type contactType, string personListName, string heading) 35 { 36 var output = new StringBuilder(); 37 var phoneNumbers = new StringBuilder(); 38 39 foreach (var p in GetLoop(personListName)) 40 { 41 var person = new ContactPerson(contactType, p.GetInteger(personListName + ".Id")); 42 43 output.Append("<strong>" + person.Title + "</strong><br/>"); 44 output.Append(person.FirstName).Append(" ").Append(person.LastName).Append("<br />"); 45 46 if (person.ShowEmail && !string.IsNullOrWhiteSpace(person.Email)) 47 { 48 output.Append("<a href=\"mailto:").Append(person.Email).Append("\">").Append(person.Email).Append("</a>").Append("<br />"); 49 } 50 if (person.ShowWorkPhone && !string.IsNullOrWhiteSpace(person.WorkPhone)) 51 { 52 phoneNumbers.Append(person.WorkPhone).Append("<br />"); 53 } 54 if (person.ShowMobilePhone && !string.IsNullOrWhiteSpace(person.MobilePhone)) 55 { 56 phoneNumbers.Append(person.MobilePhone).Append("<br />"); 57 } 58 if (person.ShowSharedPhone && !string.IsNullOrWhiteSpace(person.SharedPhone)) 59 { 60 phoneNumbers.Append(person.SharedPhone).Append("<br />"); 61 } 62 63 var phoneNumberOutput = phoneNumbers.ToString(); 64 65 if (!string.IsNullOrEmpty(phoneNumberOutput)) 66 { 67 output.Append("Telefon: ").Append(phoneNumberOutput).Append("<br/>"); 68 phoneNumbers.Clear(); 69 } 70 } 71 72 return output.ToString() == string.Empty ? string.Empty : "<h3>" + heading + "</h3>" + output; 73 } 74 75 76 private string GetTimeSpans(IEnumerable<TimeSpan> timeSpans) 77 { 78 var output = new StringBuilder(); 79 80 foreach (var ts in timeSpans) 81 { 82 output.Append(ts.FromDay); 83 84 if (ts.Closed) 85 { 86 output.Append(": Lukket"); 87 } 88 else 89 { 90 if (!string.IsNullOrEmpty(ts.ToDay)) 91 { 92 output.Append("-" + ts.ToDay); 93 } 94 95 output.Append(": "); 96 97 if(!string.IsNullOrEmpty(ts.FromHour)) 98 { 99 output.Append(ts.FromHour).Append(".").Append(ts.FromMinutes); 100 } 101 102 if(!string.IsNullOrEmpty(ts.ToHour)) 103 { 104 output.Append("-").Append(ts.ToHour).Append(".").Append(ts.ToMinutes); 105 } 106 } 107 108 output.Append("<br/>"); 109 } 110 111 return output.ToString(); 112 } 113 } 114 115 @{ 116 var orgUnitId = GetLoop("Item.Organization").Select(org => org.GetInteger("Item.Organization.Id")).FirstOrDefault(); 117 118 if (orgUnitId == 0) 119 { 120 return; 121 } 122 123 Organization orgUnit = null; 124 try 125 { 126 orgUnit = new Organization(orgUnitId); 127 } 128 catch (Exception ex) 129 { 130 throw new Exception("Cannot instantiate Organization with ID: " + orgUnitId.ToString(), ex); 131 } 132 133 } 134 135 <div class="purple-box"> 136 <div class="container rightSidebar-subpage"> 137 <div class="col-xs-12 col-sm-8 col-sm-offset-4 pBox clearfix extraPadding"> 138 <h2>@orgUnit.Name</h2> 139 <p> 140 @if (GetBoolean("Item.ShowAddress")) 141 { 142 @orgUnit.Street<text>&nbsp;</text>@orgUnit.HouseNumber<br> 143 @orgUnit.Zip<text>&nbsp;</text>@orgUnit.City<br> 144 } 145 @if (GetLoop("Item.OrganizationPhoneNumberList").Count > 0) 146 { 147 <text>Telefon: </text> @GetPhoneNumbers() 148 } 149 @if (GetBoolean("Item.ShowFaxNumber") && !string.IsNullOrWhiteSpace(orgUnit.Fax)) 150 { 151 <text>Fax: </text>@PhoneNumber.Format(orgUnit.Fax)<br /> 152 } 153 @if (GetBoolean("Item.ShowCvrNumber") && !string.IsNullOrWhiteSpace(orgUnit.CvrNumber)) 154 { 155 <text>CVR-nummer: </text>@orgUnit.CvrNumber<br /> 156 } 157 @if (GetBoolean("Item.ShowEanNumber") && !string.IsNullOrWhiteSpace(orgUnit.EanNumber)) 158 { 159 <text>EAN-nummer: </text>@orgUnit.EanNumber<br /> 160 } 161 @if (GetBoolean("Item.ShowEmail") && !string.IsNullOrWhiteSpace(orgUnit.Email)) 162 { 163 if (GetGlobalValue("Global:Area.Name") == "kommunen") 164 { 165 <a href="mailto:@orgUnit.Email">@orgUnit.Email</a><br /> 166 } 167 else 168 { 169 <a href="mailto:@orgUnit.Email">@orgUnit.Email</a><br /> 170 } 171 } 172 @if (GetBoolean("Item.ShowSendDigitalEmail") && !string.IsNullOrWhiteSpace(orgUnit.DigitalPostAddress)) 173 { 174 <a href="@orgUnit.DigitalPostAddress">Send digital post</a><br /> 175 } 176 @if (GetBoolean("Item.ShowUrlHomePage") && !string.IsNullOrWhiteSpace(orgUnit.HomepageUrl)) 177 { 178 var url = SearchEngineFriendlyURLs.GetFriendlyUrl("/Default.aspx?ID=" + orgUnit.HomepageUrl); 179 180 <a href="@url"> 181 @(orgUnit.HomepageText == "" ? orgUnit.HomepageUrl : orgUnit.HomepageText) 182 </a><br /> 183 } 184 @if (!string.IsNullOrWhiteSpace(orgUnit.Notes) && !string.IsNullOrWhiteSpace(orgUnit.Notes)) 185 { 186 @orgUnit.Notes 187 } 188 </p> 189 190 @{ 191 var openingHours = GetTimeSpans(orgUnit.OpeningHours); 192 var phoneHours = GetTimeSpans(orgUnit.PhoneHours); 193 } 194 195 @if (GetBoolean("Item.ShowExtraText")){ 196 foreach (LoopItem i in GetLoop("Item.Organization")){ 197 198 <h3>@i.GetString("Item.Organization.ExtraFieldHeadline")</h3> 199 <p>@i.GetString("Item.Organization.ExtraFieldText")</p> 200 } 201 } 202 203 @if (GetBoolean("Item.ShowOpenHours") && !string.IsNullOrWhiteSpace(openingHours)) 204 { 205 <h3>Åbningstider</h3> 206 <p> 207 @openingHours 208 </p> 209 } 210 211 @if (GetBoolean("Item.ShowPhoneHours") && !string.IsNullOrWhiteSpace(phoneHours)) 212 { 213 <h3>Telefontider</h3> 214 <p> 215 @phoneHours 216 </p> 217 } 218 219 @GetContactManagerList() 220 221 @GetContactPersonList() 222 223 </div> 224 </div> 225 </div>