EVENTS

Submit to our free events

Error executing template "Designs/Rapido/ItemPublisher/List/EventList.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_461c71e5a0104f1eaf9a188f90f81a19.Execute() in D:\Dynamicweb.net\Solutions\Peritus\ferno.staging.dynamicweb-cms.com\Files\Templates\Designs\Rapido\ItemPublisher\List\EventList.cshtml:line 10
   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 System.Web; 3 4 @{ 5 string selectedEventType = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("EventType")) ? HttpContext.Current.Request.QueryString.Get("EventType") : Translate("All"); 6 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString()); 7 8 var eventTypeField = GetLoop("ItemPublisher:ItemType.Fields").FirstOrDefault((field) => field.GetString("ItemPublisher:ItemType.Field.SystemName") == "EventType"); 9 10 Dictionary<string, string> eventTypes = eventTypeField.GetLoop("ItemPublisher:ItemType.Field.Options").ToDictionary(x => x.GetString("ItemPublisher:ItemType.Field.Option.Value"), x => x.GetString("ItemPublisher:ItemType.Field.Option.Label")); 11 12 selectedEventType = eventTypes.ContainsKey(selectedEventType) ? eventTypes[selectedEventType] : "All"; 13 14 var months = GetLoop("ItemPublisher:Items.List").Where(x => x.GetDate("ItemPublisher:Item.DateAndTime") > DateTime.Now).GroupBy(x => x.GetDate("ItemPublisher:Item.DateAndTime").Month).ToDictionary(y => y.Key, z => z.ToList()); 15 int signUpForEventPageId = GetPageIdByNavigationTag("SignUpForEventPage"); 16 } 17 18 <div class="grid__col-12"> 19 <div class="grid"> 20 <div class="grid__col-12"> 21 <div class="collection u-no-margin"> 22 <h5>@Translate("Event type")</h5> 23 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" /> 24 <div class="dropdown u-w180px dw-mod"> 25 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedEventType)</label> 26 <div class="dropdown__content dw-mod"> 27 @{ 28 query.Set("EventType", ""); 29 <div class="dropdown__item" onclick="window.location = '/Default.aspx?@query.ToString()'">@Translate("All")</div> 30 31 foreach (var options in eventTypeField.GetLoop("ItemPublisher:ItemType.Field.Options")) 32 { 33 query.Set("EventType", options.GetString("ItemPublisher:ItemType.Field.Option.Value")); 34 <div class="dropdown__item" onclick="window.location = '/Default.aspx?@query.ToString()'">@Translate(options.GetString("ItemPublisher:ItemType.Field.Option.Label"))</div> 35 } 36 } 37 </div> 38 <label class="dropdown-trigger-off" for="CategorySelector"></label> 39 </div> 40 </div> 41 </div> 42 43 <div class="grid__col-12"> 44 @foreach (var month in months) 45 { 46 string monthName = new DateTime(2010, month.Key, 1).ToString("MMMM", System.Globalization.CultureInfo.CurrentCulture); 47 48 <h3 class="grid-caption">@monthName</h3> 49 <div class="u-margin-bottom"> 50 @foreach (var eventInfo in month.Value) 51 { 52 string eventType = eventInfo.GetString("ItemPublisher:Item.EventType"); 53 string signUpLink = ""; 54 string signUpTargetType = "_self"; 55 56 if (eventInfo.GetString("ItemPublisher:Item.SignUp") == "external") 57 { 58 signUpLink = eventInfo.GetString("ItemPublisher:Item.SignUpLink"); 59 signUpTargetType = "_blank"; 60 } 61 else 62 { 63 signUpLink = "/Default.aspx?Id=" + signUpForEventPageId + "&eventId=" + eventInfo.GetString("ItemPublisher:Item.Field.Id") + "&eventName=" + HttpUtility.UrlEncode(eventInfo.GetString("ItemPublisher:Item.Title")); 64 } 65 66 <div class="u-padding u-border-bottom"> 67 <div class="grid"> 68 <div class="grid__col-sm-4 grid__col--bleed-y"> 69 <a href="/Default.aspx?ID=@eventInfo.GetString("ItemPublisher:Item.Field.PageId")">@eventInfo.GetString("ItemPublisher:Item.Title")</a> 70 </div> 71 <div class="grid__col-sm-1 grid__col--bleed-y"> 72 @eventInfo.GetDate("ItemPublisher:Item.DateAndTime").ToString("MMM. dd") 73 </div> 74 <div class="grid__col-sm-2 grid__col--bleed-y"> 75 @(eventTypes.ContainsKey(eventType) ? Translate(eventTypes[eventType]) : "") 76 </div> 77 <div class="grid__col-sm-2 grid__col--bleed-y"> 78 @*Split address parts by comma*@ 79 @string.Join(", ", (new[] { 80 eventInfo.GetString("ItemPublisher:Item.Location.City"), 81 eventInfo.GetString("ItemPublisher:Item.Location.Region"), 82 eventInfo.GetString("ItemPublisher:Item.Location.Country") }).Where(x => !string.IsNullOrEmpty(x))) 83 </div> 84 <div class="grid__col-sm-1 grid__col-6 grid__col--bleed-y"> 85 @eventInfo.GetString("ItemPublisher:Item.ParticipationFee") 86 </div> 87 <div class="grid__col-sm-2 grid__col-6 grid__col--bleed-y u-ta-right"> 88 <a href="@signUpLink" target="@signUpTargetType">@Translate("Sign up")</a> 89 </div> 90 </div> 91 </div> 92 } 93 </div> 94 } 95 </div> 96 </div> 97 </div>