Error executing template "Designs/Condition/QueryPublisher/Results.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_483ad19429634264bb72faed162fba28.Execute() in D:\dynamicweb.net\Solutions\Dansk Ride Forfund\Files\Templates\Designs\Condition\QueryPublisher\Results.cshtml:line 719
   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 Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb; 3 @using Dynamicweb.Data; 4 @using DanskRideForbund.Domain.Constant; 5 6 @using Dynamicweb; 7 @using Dynamicweb.Frontend; 8 @using System.Text.RegularExpressions; 9 10 @functions { 11 string getPageUrl(string url, string parameters = "") 12 { 13 return SearchEngineFriendlyURLs.GetFriendlyUrl(url.TrimStart('/') + (!string.IsNullOrEmpty(parameters) ? (!parameters.StartsWith("&") ? "&" : "") + parameters.Replace(" ", "+") : "")); 14 } 15 16 string getPageUrlById(int id = 0, string parameters = "") 17 { 18 return getPageUrl("Default.aspx?Id=" + (id > 0 ? id : Pageview.Page.ID), parameters); 19 } 20 21 //string getPageUrlByAreaItem(string systemName, string parameters = "", bool useFriendlyUrl = true) 22 //{ 23 // var url = Converter.ToString(Pageview.Area.Item[systemName]); 24 25 // if (string.IsNullOrEmpty(url)) return ""; 26 // else if (useFriendlyUrl) return getPageUrl(url, parameters); 27 // else return "/" + url.TrimStart('/') + (!string.IsNullOrEmpty(parameters) ? (!parameters.StartsWith("&") ? "&" : "") + parameters.Replace(" ", "+") : ""); 28 //} 29 30 string getPageUrlByNavigationTag(string tagName, string parameters = "", bool useFriendlyUrl = true) 31 { 32 var url = "Default.aspx?Id=" + GetPageIdByNavigationTag(tagName); 33 34 if (string.IsNullOrEmpty(url)) return ""; 35 else if (useFriendlyUrl) return getPageUrl(url, parameters); 36 else return "/" + url.TrimStart('/') + (!string.IsNullOrEmpty(parameters) ? (!parameters.StartsWith("&") ? "&" : "") + parameters.Replace(" ", "+") : ""); 37 } 38 39 string getLogoutUrl(bool useRedirect = true) 40 { 41 return "/Admin/Public/extranetlogoff.aspx" + (useRedirect ? "?RedirectUrl=" + Pageview.SearchFriendlyUrl : ""); 42 } 43 44 string getTranslate(string text, string defaultValue) 45 { 46 return Translate(Regex.Replace(text, "[^A-Za-z0-9:.]", ""), defaultValue); 47 } 48 } 49 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 50 @using System.Web; 51 @using Dynamicweb; 52 @using Dynamicweb.Core; 53 @using Dynamicweb.Environment; 54 @using DanskRideForbund.Domain.Core; 55 @using DanskRideForbund.DataSync.Common.Enum; 56 @using DanskRideForbund.BusinessLayer.Provider; 57 @using DanskRideForbund.Translations; 58 59 @functions 60 { 61 const bool useCommaSeparatedParamArrayValues = true; 62 const char queryValueArrayDelimiter = ','; 63 64 bool RequestParamContainsValue(string param, string value) 65 { 66 return Context.Current.Request.HasRequest(param) && (useCommaSeparatedParamArrayValues ? Context.Current.Request.QueryString[param].Split(queryValueArrayDelimiter).Contains(value) : Context.Current.Request.QueryString[param].Contains(value)); 67 } 68 69 string AddOrUpdateUrlParamValue(string absoluteUrl, string param, string newValue) 70 { 71 if (absoluteUrl == null) absoluteUrl = Context.Current.Request.Url.ToString(); 72 Uri uri = new Uri(absoluteUrl); 73 var qParts = HttpUtility.ParseQueryString(uri.Query); 74 qParts[param] = newValue; 75 return uri.AbsolutePath + "?" + qParts.ToString(); //url.AbsolutePath only returns the path portion of the URL(/ mypage.aspx); prepend url.Scheme(http) + Uri.SchemeDelimiter(://) + url.Authority 76 } 77 78 string GetPaginatedLink(int pageNum) 79 { 80 return AddOrUpdateUrlParamValue(null, "pageNum", pageNum.ToString()); 81 } 82 83 string GetTranslator(string method = "", string value = "") 84 { 85 if (!string.IsNullOrEmpty(method) && !string.IsNullOrEmpty(value)) 86 { 87 if (method == "RegionIds" || method == "RegionId") 88 { 89 return Translator.GetRegionDescription(value); 90 } 91 else if (method == "DistrictIds" || method == "DistrictId") 92 { 93 return Translator.GetDistrictDescription(value); 94 } 95 else if (method == "OfficialGroups") 96 { 97 return Translator.GetOfficialGroupDescription(value); 98 } 99 } 100 101 return Translate("SmartPage:Event." + method + "." + value, value); 102 } 103 } 104 105 @helper renderFacetEndDate(DateTime? startDate = null, DateTime? endDate = null) 106 { 107 startDate = Context.Current.Request.HasRequest("from") ? Context.Current.Request.GetDate("from") : (startDate ?? DateTime.MinValue); 108 endDate = Context.Current.Request.HasRequest("to") ? Context.Current.Request.GetDate("to") : (endDate ?? DateTime.MinValue); 109 110 <div class="form-group"> 111 <label class="label-lg" for="">@Translate("SmartPage:DatePicker.FacetName", "Dato")</label> 112 <div class="row no-gutters align-items-center"> 113 <div class="col"> 114 <div class="input-group input-group-sm"> 115 <div class="input-group-prepend"> 116 <span class="input-group-text"><i class="fas fa-calendar-alt"></i></span> 117 </div> 118 <input type="text" class="form-control form-control-sm js-datepicker js-onchange-submit" name="from" value="@(startDate != DateTime.MinValue ? startDate.Value.ToShortDateString() : "")" placeholder='@Translate("SmartPage:DatePicker.FromDate", "Fra dato")' /> 119 </div> 120 </div> 121 <div class="col-1 text-center">-</div> 122 <div class="col"> 123 <div class="input-group input-group-sm"> 124 <div class="input-group-prepend"> 125 <span class="input-group-text"><i class="fas fa-calendar-alt"></i></span> 126 </div> 127 <input type="text" class="form-control form-control-sm js-datepicker js-onchange-submit" name="to" value="@(endDate != DateTime.MinValue ? endDate.Value.ToShortDateString() : "")" placeholder='@Translate("SmartPage:DatePicker.ToDate", "Til dato")' /> 128 </div> 129 </div> 130 </div> 131 </div> 132 } 133 134 @helper renderFacetGroups(bool showOptionCount = false) 135 { 136 var index = 1; 137 138 foreach (var facetGroup in GetLoop("FacetGroups")) 139 { 140 var facets = facetGroup.GetLoop("Facets"); //.Where(i => i.GetInteger("Facet.OptionResultTotalCount") > 0); 141 142 foreach (var facet in facets.Where(i => i.GetString("Facet.RenderType") != "DistrictCheckboxes")) 143 { 144 <div class="form-group"> 145 <label class="label-lg" for="">@Translate("SmartPage:Event." + facet.GetString("Facet.Name"), facet.GetString("Facet.Name"))</label> 146 @foreach (var option in facet.GetLoop("FacetOptions").OrderBy(o => o.GetString("FacetOption.Value"))) 147 { 148 var optionLabel = GetTranslator(facet.GetString("Facet.Field"), option.GetString("FacetOption.Value")); 149 150 bool isSelected = false; 151 152 if(facet.GetString("Facet.RenderType") == "ResultsCheckboxes" && option.GetString("FacetOption.Value") == "RankingPoints" && !Converter.ToBoolean(Pageview.Area.Item["EnableRankingSystem"])) 153 { 154 continue; 155 } 156 157 if (facet.GetString("Facet.RenderType") == "RegionCheckboxes") 158 { 159 var facetChild = facets.FirstOrDefault(i => i.GetString("Facet.RenderType") == "DistrictCheckboxes"); 160 if (facetChild != null) 161 { 162 var districtProvider = new DistrictProvider(HttpContext.Current.Server, DataArea.Go); 163 var districts = districtProvider.GetDistrictsByRegionIdCached(option.GetString("FacetOption.Value")).Select(i => i.DistrictId).ToArray(); 164 165 foreach (var optionChild in facetChild.GetLoop("FacetOptions").Where(i => districts.Contains(i.GetString("FacetOption.Value")))) 166 { 167 if (optionChild.GetBoolean("FacetOption.Selected")) 168 { 169 isSelected = optionChild.GetBoolean("FacetOption.Selected"); 170 } 171 } 172 } 173 174 if(!isSelected) 175 { 176 isSelected = option.GetBoolean("FacetOption.Selected"); 177 } 178 } 179 else 180 { 181 isSelected = option.GetBoolean("FacetOption.Selected"); 182 } 183 184 <div class="form-check"> 185 <input type="checkbox" class="form-check-input js-onchange-submit js-onchange-uncheck" id="@("option-" + index)" name="@facet.GetString("Facet.QueryParameter")" value="@option.GetString("FacetOption.Value")" checked="@isSelected" /> 186 <label class="form-check-label" for="@("option-" + (index++))"> 187 @optionLabel 188 @if (showOptionCount) 189 { 190 <span class="count">(@option.GetValue("FacetOption.Count"))</span> 191 } 192 </label> 193 </div> 194 195 if (isSelected && facet.GetString("Facet.RenderType") == "RegionCheckboxes") 196 { 197 var facetChild = facets.FirstOrDefault(i => i.GetString("Facet.RenderType") == "DistrictCheckboxes"); 198 if (facetChild != null) 199 { 200 var districtProvider = new DistrictProvider(HttpContext.Current.Server, DataArea.Go); 201 var districts = districtProvider.GetDistrictsByRegionIdCached(option.GetString("FacetOption.Value")).Select(i => i.DistrictId).ToArray(); 202 203 foreach (var optionChild in facetChild.GetLoop("FacetOptions").Where(i => districts.Contains(i.GetString("FacetOption.Value")))) 204 { 205 var optionChildLabel = GetTranslator(facetChild.GetString("Facet.Field"), optionChild.GetString("FacetOption.Value")); 206 207 <div class="form-check form-check-child"> 208 <input type="checkbox" class="form-check-input js-onchange-submit" id="@("option-" + index)" name="@facetChild.GetString("Facet.QueryParameter")" value="@optionChild.GetString("FacetOption.Value")" checked="@optionChild.GetBoolean("FacetOption.Selected")" /> 209 <label class="form-check-label" for="@("option-" + (index++))"> 210 @optionChildLabel 211 @if (showOptionCount) 212 { 213 <span class="count">(@optionChild.GetValue("FacetOption.Count"))</span> 214 } 215 </label> 216 </div> 217 } 218 } 219 } 220 } 221 </div> 222 } 223 } 224 } 225 226 @helper renderAccordionRider(int registerStep = 1, string attrName = "rider") 227 { 228 var riderLoop = GetLoop("RiderLoop"); 229 230 <div class="accordion js-accordion js-checkmark" id="accordion-rider"> 231 <h4> 232 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Rider.HelperText")">@registerStep</span> 233 @Translate("SmartPage:Event.ChooseRider", "Vælg rytter/person") 234 <span class="checkmark d-none"><i class="fas fa-check text-success"></i></span> 235 </h4> 236 <div class="form-group m-0"> 237 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseFavRider" aria-expanded="true" aria-controls="collapseFavRider"><i class="@("fas fa-chevron-" + (riderLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromRiders", "Vælg fra Mine Ryttere")</label> 238 <div id="collapseFavRider" class="@("collapse" + (riderLoop.Any() ? " show" : ""))" aria-labelledby="collapseFavRider" data-parent="#accordion-rider"> 239 <div class="mb-3"> 240 <select class="form-control form-control-sm select2-single js-select2" id="search-for-rider" name="@attrName" data-placeholder="@Translate("SmartPage:Event.ChooseOption", "Vælg...")" data-select2-MinimumResultsForSearch="-1" data-select2-AllowClear="true"> 241 @foreach (var i in riderLoop) 242 { 243 <option value="@i.GetString("SmartPage:RiderId")" selected="@i.GetBoolean("SmartPage:IsDefault")">@i.GetString("SmartPage:RiderName")</option> 244 } 245 </select> 246 </div> 247 </div> 248 </div> 249 <div class="form-group m-0"> 250 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseAllRiders" aria-expanded="true" aria-controls="collapseAllRiders"><i class="@("fas fa-chevron-" + (!riderLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromAllRiders", "Vælg blandt alle ryttere/personer")</label> 251 <div id="collapseAllRiders" class="@("collapse" + (!riderLoop.Any() ? " show" : ""))" aria-labelledby="collapseAllRiders" data-parent="#accordion-rider"> 252 <select class="form-control form-control-sm select2-single js-select2" id="search-all-rider" name="@attrName" data-placeholder="@Translate("SmartPage:Event.Rider.ChooseOption", "Indtast email eller DRF-nummer")" data-select2-provider="/services/ProfileService.asmx/GetRiderSuggestions?Rider=true"></select> 253 </div> 254 </div> 255 </div> 256 } 257 258 @helper renderAccordionHorse(int registerStep = 1, string attrName = "horse") 259 { 260 var horseLoop = GetLoop("HorseLoop"); 261 262 <div class="accordion js-accordion js-checkmark" id="accordion-horse"> 263 <h4> 264 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Horse.HelperText")">@registerStep</span> 265 @Translate("SmartPage:Event.ChooseHorse", "Vælg hest") 266 <span class="checkmark d-none"><i class="fas fa-check text-success"></i></span> 267 </h4> 268 <div class="form-group m-0"> 269 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseFavHorse" aria-expanded="true" aria-controls="collapseFavHorse"><i class="@("fas fa-chevron-" + (horseLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromHorses", "Vælg fra Mine Heste")</label> 270 <div id="collapseFavHorse" class="@("collapse" + (horseLoop.Any() ? " show" : ""))" aria-labelledby="collapseFavHorse" data-parent="#accordion-horse"> 271 <div class="mb-3"> 272 <select class="form-control form-control-sm select2-single js-select2" id="search-for-horse" name="@attrName" data-placeholder="@Translate("SmartPage:Event.ChooseOption", "Vælg...")" data-select2-MinimumResultsForSearch="-1" data-select2-AllowClear="true"> 273 @foreach (var i in horseLoop) 274 { 275 <option value="@i.GetString("SmartPage:HorseId")" selected="@i.GetBoolean("SmartPage:IsDefault")">@i.GetString("SmartPage:HorseName") (@i.GetString("SmartPage:HorseDisplayId"))</option> 276 } 277 </select> 278 </div> 279 </div> 280 </div> 281 <div class="form-group m-0"> 282 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseAllHorses" aria-expanded="true" aria-controls="collapseAllHorses"><i class="@("fas fa-chevron-" + (!horseLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromAllHorses", "Vælg blandt alle heste")</label> 283 <div id="collapseAllHorses" class="@("collapse" + (!horseLoop.Any() ? " show" : ""))" aria-labelledby="collapseAllHorses" data-parent="#accordion-horse"> 284 <select class="form-control form-control-sm select2-single js-select2" id="search-all-horse" name="@attrName" data-placeholder="@Translate("SmartPage:Event.Horse.ChooseOption", "Indtast Id nummer")" data-select2-provider="/services/ProfileService.asmx/GetHorseSuggestions?Horse=true"></select> 285 </div> 286 </div> 287 </div> 288 } 289 290 @helper renderAccordionClub(int registerStep = 1, string attrName = "club") 291 { 292 var clubLoop = GetLoop("ClubLoop"); 293 294 <div class="accordion js-accordion js-checkmark" id="accordion-club"> 295 <h4> 296 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Club.HelperText")">@registerStep</span> 297 @Translate("SmartPage:Event.ChooseClub", "Vælg klub") 298 <span class="checkmark d-none"><i class="fas fa-check text-success"></i></span> 299 </h4> 300 <div class="form-group m-0"> 301 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseFavClub" aria-expanded="true" aria-controls="collapseFavClub"><i class="@("fas fa-chevron-" + (clubLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromClubs", "Vælg fra Mine Klubber")</label> 302 <div id="collapseFavClub" class="@("collapse" + (clubLoop.Any() ? " show" : ""))" aria-labelledby="collapseFavClub" data-parent="#accordion-club"> 303 <div class="mb-3"> 304 <select class="form-control form-control-sm select2-single mb-3 js-select2" id="search-for-club" name="@attrName" data-placeholder="@Translate("SmartPage:Event.ChooseOption", "Vælg...")" data-select2-MinimumResultsForSearch="-1" data-select2-AllowClear="true"> 305 @foreach (var i in clubLoop) 306 { 307 <option value="@i.GetString("SmartPage:ClubId")" selected="@i.GetBoolean("SmartPage:IsDefault")">@i.GetString("SmartPage:ClubName")</option> 308 } 309 </select> 310 </div> 311 </div> 312 </div> 313 <div class="form-group m-0"> 314 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseAllClubs" aria-expanded="true" aria-controls="collapseAllClubs"><i class="@("fas fa-chevron-" + (!clubLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromAllClubs", "Vælg blandt alle klubber")</label> 315 <div id="collapseAllClubs" class="@("collapse" + (!clubLoop.Any() ? " show" : ""))" aria-labelledby="collapseAllClubs" data-parent="#accordion-club"> 316 <select class="form-control form-control-sm select2-single js-select2" id="search-all-club" name="@attrName" data-placeholder="@Translate("SmartPage:Event.Club.ChooseOption", "Indtast navn/fork")" data-select2-provider="@getPageUrlByNavigationTag("ClubSearchPage", "Club=true")"></select> 317 </div> 318 </div> 319 </div> 320 } 321 322 @helper renderAccordionComment(int registerStep = 1, string attrName = "comment") 323 { 324 <div> 325 <h4> 326 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Club.HelperText")">@registerStep</span> 327 @Translate("SmartPage:Event.ChooseComments", "Bemærkning") 328 </h4> 329 <textarea class="form-control form-control-sm js-maxlength js-validate" id="comment" name="comment" maxlength="255" data-maxlength="#js-maxlength" data-validation-message="Du har indtastet et ugyldigt tegn i bemærknings feltet. Fjern tegnet og prøv igen."></textarea> 330 <span class="help-inline maxlength">Tegn tilbage <span id="js-maxlength"></span></span> 331 </div> 332 } 333 334 @helper renderPagination(int _pagecount, int _currentpage) 335 { 336 var groupAmount = 5; 337 var isDotsPrinted = false; 338 339 @*<ul class="pagination"> 340 <li class="page-item disabled"> 341 <a class="page-link" href="#" tabindex="-1">Previous</a> 342 </li> 343 <li class="page-item"><a class="page-link" href="#">1</a></li> 344 <li class="page-item active"> 345 <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a> 346 </li> 347 <li class="page-item"><a class="page-link" href="#">3</a></li> 348 <li class="page-item"> 349 <a class="page-link" href="#">Next</a> 350 </li> 351 </ul>*@ 352 353 if (_pagecount > 1) 354 { 355 <ul class="pagination pagination-sm"> 356 @{ 357 if (_currentpage > 1) 358 { 359 <li class="page-item"><a href="@GetPaginatedLink(_currentpage - 1)" class="page-link">&lt; Forrige</a></li> 360 } 361 362 for (int i = 1; i <= _pagecount; i++) 363 { 364 if (i != _currentpage) 365 { 366 if (i == 1 || (i >= (_currentpage - 2) && (i < _currentpage || i <= groupAmount)) || (i <= (_currentpage + 2) && (i > _currentpage || i >= (_pagecount - groupAmount))) || i == _pagecount) 367 { 368 <li class="page-item"><a href="@GetPaginatedLink(i)" class="page-link" data-page="@i">@i</a></li> 369 } 370 else if (!isDotsPrinted) 371 { 372 <li class="page-item disabled"><span class="page-link">..</span></li> 373 isDotsPrinted = true; 374 } 375 } 376 else 377 { 378 <li class="page-item active"><a href="@GetPaginatedLink(i)" class="page-link" data-page="@i">@i</a></li> 379 isDotsPrinted = false; 380 } 381 } 382 383 if (_currentpage < _pagecount) 384 { 385 <li class="page-item"><a href="@GetPaginatedLink(_currentpage + 1)" class="page-link">Næste &gt;</a></li> 386 } 387 } 388 </ul> 389 } 390 } 391 392 @helper renderPageSizeDropdown(string _attributeId, int _currentPageSize, List<int> _availablePageSizes, bool showOptionAll) 393 { 394 var url = Converter.ToString(Context.Current.Request.RawUrl); 395 396 <div class="pagination-size"> 397 <select class="form-control form-control-sm js-select2 js-onchange-href" id='@_attributeId' name="pagesize" autocomplete="off" data-select2-minimumResultsForSearch="-1"> 398 @foreach (var size in _availablePageSizes) 399 { 400 <option value="@QueryHelper.ReplaceQueryStringParam(url, "pagesize", Converter.ToString(size))" selected="@(size == _currentPageSize)">@string.Format(Translate("SmartPage:PageSize.Item", "vis {0}"), size)</option> 401 } 402 @if (showOptionAll) 403 { 404 <option value="@QueryHelper.ReplaceQueryStringParam(url, "pagesize", Converter.ToString(999999))" selected="@(999999 == _currentPageSize)">@Translate("SmartPage:PageSize.AllItems", "vis alle")</option> 405 } 406 </select> 407 </div> 408 } 409 410 @helper renderOrderByDropdown(string _attributeId, Dictionary<string, string> _availableOrderbys) 411 { 412 var urlPath = System.Web.HttpContext.Current.Request.Url.PathAndQuery; 413 414 <div class="pagination-orderby"> 415 @Translate("Smartpage:GlobalHelper.OrderBy.Label", "Sorter efter:")&nbsp;&nbsp; 416 </div> 417 <div class="pagination-orderby"> 418 <select class="form-control form-control-sm js-select2 js-onchange-href" id='@_attributeId' name="orderby" autocomplete="off" data-select2-minimumResultsForSearch="-1"> 419 @foreach (var option in _availableOrderbys) 420 { 421 <option value="@option.Value" selected="@(urlPath.ToLower() == option.Value.ToLower())">@option.Key</option> 422 } 423 </select> 424 </div> 425 } 426 427 @functions { 428 string displayMode(string defaultMode = "table") 429 { 430 if (!string.IsNullOrEmpty(Context.Current.Request.GetString("display-mode"))) 431 { 432 Context.Current.Session["SmartPage:Event.DisplayMode"] = Context.Current.Request.GetString("display-mode"); 433 } 434 else if (string.IsNullOrEmpty(Converter.ToString(Context.Current.Session["SmartPage:Event.DisplayMode"]))) 435 { 436 Context.Current.Session["SmartPage:Event.DisplayMode"] = defaultMode; 437 } 438 439 return Converter.ToString(Context.Current.Session["SmartPage:Event.DisplayMode"]); 440 } 441 } 442 443 @helper renderDisplayMode(string mode = "table") // options: 'table' and 'grid' 444 { 445 var url = Converter.ToString(Context.Current.Request.RawUrl); 446 447 <div class="list-display-type btn-group" role="group" aria-label="Display mode"> 448 <a href='@QueryHelper.ReplaceQueryStringParam(url, "display-mode", "table")' class="btn btn-secondary btn-sm" disabled="@(mode == "table")"><i class="fas fa-bars"></i></a> 449 <a href='@QueryHelper.ReplaceQueryStringParam(url, "display-mode", "grid")' class="btn btn-secondary btn-sm" disabled="@(mode == "grid")"><i class="fas fa-th"></i></a> 450 </div> 451 } 452 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 453 @using Dynamicweb; 454 @using Dynamicweb.Environment; 455 456 @*TODO: Set translation *@ 457 458 @functions 459 { 460 public class HorsesFacet 461 { 462 public string AnimalAccount { get; set; } 463 public string HorseName { get; set; } 464 public int Count { get; set; } 465 } 466 } 467 468 @helper RenderResultSearchBox() 469 { 470 var requestQ = Context.Current.Request.GetString("q"); 471 var requestClub = Context.Current.Request.GetString("club"); 472 var requestClubId = Context.Current.Request.GetString("clubid"); 473 474 if (!string.IsNullOrEmpty(requestClub)) 475 { 476 if (!string.IsNullOrEmpty(requestClubId)) 477 { 478 <input type="hidden" class="js-select2-remove" name="ClubId" value="@requestClubId" /> 479 } 480 481 <input type="hidden" class="js-select2-remove" name="Club" value="@requestClub" /> 482 } 483 484 <fieldset class="filter"> 485 <legend class="header">@Translate("SmartPage:ResultHelper.SearchLegend", "Søg")</legend> 486 <div class="p-3"> 487 <div class="form-group"> 488 <select class="form-control form-control-sm js-select2" id="search-for-result" name="q" data-placeholder="@Translate("SmartPage:Course.SearchDefault", "Arrangør/fork/navn")" data-select2-provider="@getPageUrlByNavigationTag("ResultSearchPage")" required="@true"> 489 @if (!string.IsNullOrEmpty(requestClub)) 490 { 491 <option value="@requestClub" selected="@true">@requestClub</option> 492 } 493 else if (!string.IsNullOrEmpty(requestQ)) 494 { 495 <option value="@requestQ" selected="@true">@requestQ</option> 496 } 497 </select> 498 </div> 499 <div class="mt-2 text-right"> 500 <a href='@getPageUrlById()' class="btn btn-secondary btn-sm float-left" title="">@Translate("SmartPage:ResultHelper.ClearFilter", "Nulstil kalender")</a> 501 <button type="submit" class="btn btn-primary btn-sm" id="search-result-button">@Translate("SmartPage:ResultHelper.SearchButton", "Go!")</button> 502 </div> 503 </div> 504 </fieldset> 505 } 506 507 @helper RenderRiderHorseSearchBox(List<LoopItem> results, bool disabled = false) 508 { 509 <fieldset class="filter"> 510 <legend class="header">@Translate("SmartPage:ResultHelper.SearchLegend", "Søg")</legend> 511 <div class="p-3"> 512 <div class="form-group"> 513 @RenderRiderFormGroup(results, disabled) 514 </div> 515 <div class="form-group mt-2"> 516 @RenderHorseFormGroup(results, disabled) 517 </div> 518 <div class="mt-2 text-right"> 519 <a href='@getPageUrlById()' class="btn btn-secondary btn-sm float-left" title="">@Translate("SmartPage:Rider.ClearSearch", "Nulstil søgning")</a> 520 <button type="submit" class="btn btn-primary btn-sm" id="search-result-riderhorse-button">@Translate("SmartPage:Event.Result.SearchButton", "Go!")</button> 521 </div> 522 </div> 523 </fieldset> 524 } 525 526 @helper RenderRiderFormGroup(List<LoopItem> results, bool disabled = false) 527 { 528 var requestRider = HttpUtility.UrlDecode(Context.Current.Request.GetString("rider")); 529 var requestRiderId = Context.Current.Request.GetString("riderid"); 530 531 <input type="hidden" class="js-select2-clear" name="Rider" value="@requestRider" autocomplete="off" /> 532 533 <label for="search-for-rider">@Translate("Smartpage:ResultPageRiderHorse.Rider", "Rytter")</label> 534 <select class="form-control form-control-sm js-select2" id="search-for-rider" name="RiderId" placeholder="@Translate("SmartPage:Event.Rider.SearchDefault", "Navn eller DRF-nummer")" data-select2-provider="/services/ProfileService.asmx/GetRiderSuggestions?Rider=true" disabled="@disabled"> 535 @if (!string.IsNullOrEmpty(requestRider) && !string.IsNullOrEmpty(requestRiderId)) 536 { 537 <option value="@requestRiderId" selected="@true">@requestRider</option> 538 } 539 </select> 540 } 541 542 @helper RenderHorseFormGroup(List<LoopItem> results, bool disabled = false) 543 { 544 var requestHorse = HttpUtility.UrlDecode(Context.Current.Request.GetString("horse")); 545 var requestHorseId = Context.Current.Request.GetString("horseid"); 546 547 <input type="hidden" class="js-select2-clear" name="Horse" value="@requestHorse" autocomplete="off" /> 548 549 <label for="search-for-horse">@Translate("Smartpage:ResultPageRiderHorse.Horse", "Hest")</label> 550 <select class="form-control form-control-sm js-select2" id="search-for-horse" name="HorseId" placeholder="@Translate("SmartPage:Event.Horse.SearchDefault", "Navn eller id-nummer")" data-select2-provider="/services/ProfileService.asmx/GetHorseSuggestions?Horse=true" disabled="@disabled"> 551 @if (!string.IsNullOrEmpty(requestHorse) && !string.IsNullOrEmpty(requestHorseId)) 552 { 553 <option value="@requestHorseId" selected="@true">@requestHorse</option> 554 } 555 </select> 556 } 557 558 @helper renderFacetHorseGroup(List<HorsesFacet> horsesFacets = null) 559 { 560 if (horsesFacets != null) 561 { 562 var requestHorse = Context.Current.Request.GetString("HorseId"); 563 564 <div class="form-group"> 565 <label class="label-lg" for="">@Translate("SmartPage:Event.Horses", "Horses")</label> 566 @foreach (var horses in horsesFacets.OrderBy(o => o.AnimalAccount)) 567 { 568 <div class="form-check"> 569 <input type="checkbox" class="form-check-input js-onchange-submit" id="" name="HorseId" value="@horses.AnimalAccount" checked="@requestHorse.Contains(horses.AnimalAccount)" /> 570 <label class="form-check-label" for="">@horses.HorseName @*<span class="count">(@horses.Count)</span>*@</label> 571 </div> 572 } 573 </div> 574 } 575 } 576 577 @{ 578 var results = GetLoop("QueryResultItem"); 579 List<int> resultsPageSizes = new List<int>() { { 30 }, { 60 }, { 90 } }; 580 var mode = displayMode(); 581 } 582 583 <div class="row"> 584 <h1 class="col-12">@Pageview.CurrentParagraph.Header <span id="entries-total">@(GetInteger("QueryResult.TotalCount") > 0 ? string.Format("({0})", GetString("QueryResult.TotalCount")) : "")</span></h1> 585 </div> 586 <div class="row"> 587 <div class="col-md-3 sidebar"> 588 <form class="js-form-facets" method="GET" action="@getPageUrlById()"> 589 <div class="shadow"> 590 @RenderResultSearchBox() 591 </div> 592 <div class="submenu"> 593 @RenderNavigation(new { ParentTag = "results", StartLevel = 3, EndLevel = 3, Template = "SubMenu.xslt", ExpandMode = "all", Style = "shadow", Heading = "Find andre resultater", HeadingStyle = "h4" }) 594 </div> 595 <div class="shadow p-3"> 596 @renderFacetEndDate(DateTime.Now.Date.AddMonths(-3), DateTime.Now.Date) 597 @renderFacetGroups(true) 598 </div> 599 </form> 600 601 </div> 602 <div class="col-md-9"> 603 @if (results.Any()) 604 { 605 <div class="pagination-container pagination-top"> 606 <input id="pagesize" type="hidden" name="pageNum" value="@GetString("DwPaging.CurrentPage")" /> 607 @renderPagination(GetInteger("DwPaging.PageCount"), GetInteger("DwPaging.CurrentPage")) 608 @renderPageSizeDropdown("pagesize-top", GetInteger("DwPaging.PageSize"), resultsPageSizes, true) 609 @renderDisplayMode(mode) 610 </div> 611 612 if (mode == "table") 613 { 614 <table id="entries" class="table table-condensed table-hover table-striped clickable shadow responsive"> 615 <colgroup> 616 <col width="@((100/12)*5)%" /> 617 <col width="@((100/12)*4)%" /> 618 <col width="@((100/12)*3)%" /> 619 </colgroup> 620 <thead> 621 <tr> 622 <th>@Translate("SmartPage:Event.EventInformation", "Stævneinformation")</th> 623 <th>@Translate("SmartPage:Event.DateAndDeadline", "Dato & Anmeldelsesfrist")</th> 624 <th>@Translate("SmartPage:Event.DisciplineAndLevel", "Disciplin & Niveau")</th> 625 </tr> 626 </thead> 627 <tbody> 628 @foreach (LoopItem i in results) 629 { 630 var resultLink = getPageUrlByNavigationTag("ResultPage", "EventId=" + i.GetString("EventId")); 631 632 <tr itemscope itemtype="http://schema.org/SportsEvent"> 633 <td> 634 <div class="club" itemprop="location" itemscope itemtype="http://schema.org/Place"> 635 <span class="org" itemprop="name">@i.GetString("ClubName").ToUpper()</span> (@i.GetString("DistrictId")) 636 <div class="adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> 637 <meta itemprop="streetAddress" content="@i.GetString("Address")" /> 638 <meta itemprop="postalCode" content="@i.GetString("ZipCode")" /> 639 <meta itemprop="addressLocality" content="@i.GetString("City")" /> 640 </div> 641 </div> 642 <div class="name" itemprop="name"> 643 <a href='@resultLink' itemprop="url">@i.GetString("EventName")</a> 644 @if (!string.IsNullOrEmpty(i.GetString("GameLevel"))) 645 { 646 <span class="gamelevel">(@i.GetString("GameLevel"))</span> 647 } 648 </div> 649 </td> 650 <td> 651 <div class="interval">@i.GetDate("StartDate").ToShortDateString() - @i.GetDate("EndDate").ToShortDateString()</div> 652 <meta itemprop="startDate" content="@i.GetDate("StartDate").ToString("o")" /> 653 <meta itemprop="endDate" content="@i.GetDate("EndDate").ToString("o")" /> 654 @if (i.GetDate("RegistrationDeadline").Date < DomainConstants.MaximumDate) 655 { 656 <span class="deadline">@i.GetDate("RegistrationDeadline").ToShortDateString()</span> 657 } 658 <span class="status"> 659 (@Translate("SmartPage:Event.EventStatus." + i.GetString("EventStatusEnum"), i.GetString("EventStatusEnum"))) 660 </span> 661 </td> 662 <td> 663 @if (i.GetValue("Disciplines") != null) 664 { 665 <ul class="disciplines"> 666 @foreach (var j in (string[])i.GetValue("Disciplines")) 667 { 668 <li>@Translate("SmartPage:Event.Discipline." + j, j)</li> 669 } 670 </ul> 671 } 672 <div class="category"> 673 @Translate("SmartPage:Event.Category." + i.GetString("AnimalCategoryEnum"), i.GetString("AnimalCategoryEnum")) 674 </div> 675 </td> 676 </tr> 677 } 678 </tbody> 679 </table> 680 } 681 else 682 { 683 <div class="row" id="entries"> 684 @foreach (var i in results) 685 { 686 var resultLink = getPageUrlByNavigationTag("ResultPage", "EventId=" + i.GetString("EventId")); 687 688 <div class="col-lg-4 event-grid-box"> 689 <div class="shadow" onclick="window.location='@resultLink'"> 690 <div class="event-header"> 691 <div class="event-label"> 692 <span class="month"> 693 @i.GetDate("StartDate").ToString("MMM") 694 </span> 695 <br /> 696 <span class="year"> 697 @i.GetDate("StartDate").Year 698 </span> 699 </div> 700 <div class="event-short-info"> 701 <span class="date-interval"> 702 @i.GetDate("StartDate").ToShortDateString() - @i.GetDate("EndDate").ToShortDateString() 703 </span> 704 <p class="club">@i.GetString("ClubName").ToUpper()</p> 705 </div> 706 </div> 707 <p class="name">@i.GetString("EventName")</p> 708 <table> 709 <tr> 710 <th>@Translate("Smartpage:Results.District", "Distrikt")</th> 711 <td>@i.GetString("DistrictId")</td> 712 </tr> 713 @if (!i.GetBoolean("SmartPage:Event.IsPonyMeasurement")) 714 { 715 <tr> 716 <th>@Translate("Smartpage:Results.Disciplin", "Disciplin")</th> 717 <td> 718 <ul class="disciplines"> 719 @foreach (var j in (string[])i.GetValue("Disciplines")) 720 { 721 <li>@Translate("SmartPage:Event.Discipline." + j, j)</li> 722 } 723 </ul> 724 </td> 725 </tr> 726 } 727 <tr> 728 <th>@Translate("Smartpage:Results.Niveau", "Niveau")</th> 729 <td>@i.GetString("GameLevel")</td> 730 </tr> 731 <tr> 732 <th>@Translate("Smartpage:Results.Type", "Type")</th> 733 <td>@Translate("SmartPage:Event.Category." + i.GetString("AnimalCategoryEnum"), i.GetString("AnimalCategoryEnum"))</td> 734 </tr> 735 </table> 736 </div> 737 </div> 738 } 739 </div> 740 } 741 742 <div class="pagination-container pagination-bottom"> 743 @renderPagination(GetInteger("DwPaging.PageCount"), GetInteger("DwPaging.CurrentPage")) 744 @renderPageSizeDropdown("pagesize-bottom", GetInteger("DwPaging.PageSize"), resultsPageSizes, true) 745 @renderDisplayMode(mode) 746 </div> 747 } 748 else 749 { 750 <div class="content shadow"> 751 @Pageview.CurrentParagraph.Text 752 </div> 753 } 754 </div> 755 </div>