Exception in template (NemlejeV2/Tenancy2.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.aabffccacffeaeeb.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@using System.Globalization @using System.Security.Cryptography.X509Certificates @using Dynamicweb @using Dynamicweb.Content.Items @using Dynamicweb.Modules.Common; @using System.Web; @using System.Net; @using System.IO; @using System.Collections @{ var disclaimerText = @RenderParagraphContent(1746); } <!--MODULE--> <div class="container-fluid apartment-detail"> @{ LoopItem tenancyItem = GetLoop("Tenancies").FirstOrDefault(); var departmentLink = Pageview.Area.Item["DepartmentPageID"] + "&amp;moduleAction=displayDepartment&amp;departmentNo=" + @tenancyItem.GetValue("DepartmentNo") + "&amp;companyNo=" + @tenancyItem.GetValue("CompanyNo"); var printUrl = ""; var nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone(); nfi.NumberGroupSeparator = "."; var test = ""; var tooltipTxt = Pageview.Area.Item["TenancyTooltip"]; } @functions{ public struct FileItem { public string Path; public string Filename; public string FileType; public bool Selected; } public struct FactItem { public string Text; public string Heading; public string MouseOver; public string IconClass; } } @{ Hashtable texts = new Hashtable(); foreach (LoopItem t in GetLoop("Texts")) { texts.Add(t.GetString("Headline").Trim(), t.GetString("Text").Trim()); } Hashtable premises = new Hashtable(); foreach (LoopItem t in tenancyItem.GetLoop("Premises")) { if(!premises.ContainsKey(t.GetString("Text").Trim())){ premises.Add(t.GetString("Text").Trim(), t.GetString("PremisNo")); } } foreach (DictionaryEntry dictionaryEntry in premises) { @*<p>@dictionaryEntry.Key : @dictionaryEntry.Value</p>*@ } List<FactItem> facts = new List<FactItem>(); facts.Add(new FactItem() { Heading = "Antal værelser", Text = tenancyItem.GetString("Rooms"), MouseOver = "", IconClass = "verelser" }); facts.Add(new FactItem() { Heading = "Størrelse", Text = tenancyItem.GetString("TenancySqm") + " m2", MouseOver = "", IconClass = "house" }); // facts.Add(new FactItem() { Heading = "Lejemålstype", Text = tenancyItem.GetString("TenancyTypeName") , MouseOver = "", IconClass = "house" }); var petsallow = ""; var husdyrText = ""; bool firstoftheloop = true; foreach(LoopItem it in GetLoop("Tenancies") ) { if(firstoftheloop) { husdyrText = it.GetString("PetsText"); if(husdyrText.Contains("er tilladt")) { petsallow = "Ja"; } else { petsallow = "Nej"; } } firstoftheloop = false; } //if (texts.ContainsKey("Pets")) //{ // husdyrText = texts["Husdyr"].ToString(); // if (texts["Husdyr"].ToString().StartsWith("Nej")) // { // petsallow = "Nej"; // } // else // { // petsallow = "Ja"; // } //} facts.Add(new FactItem() { Heading = "Husdyr", Text = petsallow, MouseOver = husdyrText, IconClass = "pets" }); /// facts.Add(new FactItem() { Heading = "Husdyr", Text = petsallow, MouseOver = husdyrText, IconClass = "pets" }); if (texts.ContainsKey("Antenne")){facts.Add(new FactItem() { Heading = "Antenne", Text = "info", MouseOver = texts["Antenne"].ToString(), IconClass = "tv" });} if (texts.ContainsKey("Varmeanlæg")) { facts.Add(new FactItem() { Heading = "Varmeanlæg", Text = "info", MouseOver = texts["Varmeanlæg"].ToString(), IconClass = "info" }); } var balcony = "Nej"; var balconyText = "Nej"; //if(premises.ContainsKey("Altan")){ // balcony="Ja"; // balconyText = "Altan"; //} if (premises.ContainsKey("Altan/Terrasse")) { balcony = "Ja"; //balconyText = "Altan/Terrasse"; balconyText = ""; } facts.Add(new FactItem() { Heading = "Altan/Terasse", Text = balcony, MouseOver = balconyText, IconClass = "altan" }); var garden = "Nej"; if (premises.ContainsKey("Have")) { garden = "Ja"; } //// if (premises.ContainsKey("Uden have")){garden = "Nej";} facts.Add(new FactItem() { Heading = "Have", Text = garden, MouseOver = "", IconClass = "garden" }); //if (premises.ContainsKey("Uden trapper")) //{ // facts.Add(new FactItem() { Heading = "Uden trapper", Text = garden, MouseOver = "", IconClass = "stairs" }); //} /////////////////////////////////////////// @* if (premises.ContainsKey("Køkken fælles")) { facts.Add(new FactItem() { Heading = "Køkken fælles", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Bad fælles")) { facts.Add(new FactItem() { Heading = "Bad fælles", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Toilet fælles")) { facts.Add(new FactItem() { Heading = "Toilet fælles", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Inventar")) { facts.Add(new FactItem() { Heading = "Inventar", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Delvis inventar")) { facts.Add(new FactItem() { Heading = "Delvis inventar", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Hems")) { facts.Add(new FactItem() { Heading = "Hems", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Fællesvaskeri")) { facts.Add(new FactItem() { Heading = "Fællesvaskeri", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Fælles gårdanl_tagterrasse")) { facts.Add(new FactItem() { Heading = "Fælles gårdanl_tagterrasse", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Delvis inventar")) { facts.Add(new FactItem() { Heading = "Delvis inventar", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Loft_kælderrum")) { facts.Add(new FactItem() { Heading = "Loft kælderrum", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Cykelkælder")) { facts.Add(new FactItem() { Heading = "Cykelkælder", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Garage")) { facts.Add(new FactItem() { Heading = "Garage", Text = "Ja", MouseOver = "", IconClass = "garage" }); } if (premises.ContainsKey("El inkl i leje")) { facts.Add(new FactItem() { Heading = "El inkl i leje", Text = "Ja", MouseOver = "", IconClass = "garage" }); } if (premises.ContainsKey("Varme inkl Leje")) { facts.Add(new FactItem() { Heading = "Varme inkl Leje", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Vand inkl Leje")) { facts.Add(new FactItem() { Heading = "Vand inkl Leje", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Elevator")) { facts.Add(new FactItem() { Heading = "Elevator", Text = "Ja", MouseOver = "", IconClass = "elevator" }); //// } /// have here if (premises.ContainsKey("Fjernvarme naturgas")) { facts.Add(new FactItem() { Heading = "Fjernvarme naturgas", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Centralvarme med olie")) { facts.Add(new FactItem() { Heading = "Centralvarme med olie", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Opvarme via el")) { facts.Add(new FactItem() { Heading = "Opvarme via el", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Opvarme ved andet")) { facts.Add(new FactItem() { Heading = "Opvarme ved andet", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Køkken")) { facts.Add(new FactItem() { Heading = "Køkken", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Bad")) { facts.Add(new FactItem() { Heading = "Bad", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Toilet")) { facts.Add(new FactItem() { Heading = "Toilet", Text = "", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Varme ikke inkl Leje")) { facts.Add(new FactItem() { Heading = "Varme ikke inkl Leje", Text = "", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Vand ikke inkl Leje")) { facts.Add(new FactItem() { Heading = "Vand ikke inkl Leje", Text = "", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Aflæsning til Energi Midt")) { facts.Add(new FactItem() { Heading = "Aflæsning til Energi Midt", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Vandafledning ink leje")) { facts.Add(new FactItem() { Heading = "Vandafledning ink leje", Text = "", MouseOver = "", IconClass = "info" }); } *@ //////////////////////////////////////////////// var oneFloor = premises.ContainsKey("1 plan"); var shareable = premises.ContainsKey("Delebolig"); var listOfFiles = new List<FileItem>(); foreach (LoopItem item in tenancyItem.GetLoop("Files")) { if (item.GetValue("TypeName").ToString() == "departmentPic") { var anItem = new FileItem(); anItem.Filename = item.GetValue("FileName").ToString(); anItem.Path = item.GetValue("Path").ToString(); anItem.FileType = item.GetValue("TypeName").ToString(); listOfFiles.Add(anItem); } } foreach (LoopItem item in tenancyItem.GetLoop("Files")) { if (item.GetValue("TypeName").ToString() == "departmentPictures") { var anItem = new FileItem(); anItem.Filename = item.GetValue("FileName").ToString(); anItem.Path = item.GetValue("Path").ToString(); anItem.FileType = item.GetValue("TypeName").ToString(); listOfFiles.Add(anItem); } } if (listOfFiles.Count == 0) { foreach (LoopItem item in tenancyItem.GetLoop("Files")) { if (item.GetValue("TypeName").ToString() == "departmentPic") { var anItem = new FileItem(); anItem.Filename = item.GetValue("FileName").ToString(); anItem.Path = item.GetValue("Path").ToString(); anItem.FileType = item.GetValue("TypeName").ToString(); listOfFiles.Add(anItem); } } } if (listOfFiles.Count == 0) { foreach (LoopItem item in tenancyItem.GetLoop("Files")) { if (@item.GetValue("TenancySelect").ToString() == "False" && @item.GetValue("TypeName").ToString() != "EGBluePrint") /// was "True" { var anItem = new FileItem(); anItem.Filename = item.GetValue("FileName").ToString(); anItem.Path = item.GetValue("Path").ToString(); anItem.FileType = item.GetValue("TypeName").ToString(); listOfFiles.Add(anItem); } } } <div id="carousel-example-generic" class="carousel slide " data-ride="carousel"> <!-- Indicators --> <div class="indicators-wrapper"> <ol class="carousel-indicators hidden-xs cars"> @{ var counter = -1; } @foreach (FileItem item in listOfFiles) { counter++; var active = ""; if (counter == 0) { active = "active"; } <li data-target="#carousel-example-generic" data-slide-to="@counter" class="@active"></li> } @{ if (counter < 1) { <li data-target="#carousel-example-generic" data-slide-to="0" class="inactive">></li> } } </ol> </div> <div class="carousel-inner" role="listbox"> @{ counter = -1;} @foreach (FileItem item in listOfFiles) { var extralargeImageSliderUrl = "/admin/public/getImage.ashx?Image=" + WebUtility.UrlEncode(item.Path) + "/" + item.Filename + "&amp;AlternativeImage=/files/templates/designs/bleau-solutionset/img/NoApartmentPictureAfd.png&amp;Resolution=75&amp;Compression=70&amp;Width=2048&amp;Height=600"; counter++; var active = ""; if (counter == 0) { active = "active"; } <div class="item @active"> <div class="carousel-img" style="background: url('@extralargeImageSliderUrl') center center no-repeat"></div> </div> } @{ if (counter == -1) { var imgLink = "/admin/public/getImage.ashx?Image=files/templates/designs/bleau-solutionset/img/NoApartmentPictureAfd.png&amp;AlternativeImage=/files/templates/designs/bleau-solutionset/img/NoApartmentPictureAfd.png&amp;Resolution=75&amp;Compression=70&amp;Width=2048&amp;Height=600"; <div class="item active"> <div class="carousel-img" style="background: url('@imgLink') center center no-repeat"></div> </div> } } </div> @{ if (counter >= 1) { <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <div class="boxie-left"></div> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <div class="boxie-right"></div> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> } } <div class="app-info"> <div class="app-info-container"> <p class="title">@tenancyItem.GetString("Address") @if(tenancyItem.GetString("InternetAvailable")=="True"){ <span> @tenancyItem.GetString("Location")</span> } </p> <p class="">@tenancyItem.GetString("ZipCity")</p> </div> @*<p class="ellipsis ellip">@tenancyItem.GetString("Address") <pre>@tenancyItem.GetString("Address")</pre> </p> <p class="ellipsis ellip">@tenancyItem.GetString("ZipCity") <pre>@tenancyItem.GetString("ZipCity") </pre> </p>*@ </div> </div> } <div class="facts-apartment"> <div class="container stickem-container"> <div class="col-sm-12 col-md-4 col-md-push-8 apart-info"> <div class="apartment-info stickem"> <div class="table"> <div class="table-row large"> @{ if (@tenancyItem.GetDouble("RentGross") > 0) { <div class="row-col-left left-husl">Husleje <span class="small-pr-mdr">pr. mdr.</span> @*<span data-toggle="modal" data-target="#myModal" class="glyphicon glyphicon-info-sign infosign-notice" aria-hidden="true"></span>*@ <span data-toggle="tooltip" data-placement="bottom" title="@disclaimerText"><i class="show-tooltip icon-question-sign"></i></span> @*<span tooltip data-toggle="tooltip" data-delay="{'show':500,'hide':500}" data-placement="right" title="@disclaimerText" class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>*@ </div> <div class="row-col-right husl-right">Kr. @tenancyItem.GetDouble("RentGross").ToString("N0", nfi)</div> @*<span class="small">pr. mdr.</span>*@ } } </div> <div class="table-row large"> @{ if (@tenancyItem.GetDouble("Deposit") > 0) { <div class="row-col-left">Indskud</div> <div class="row-col-right">Kr. @tenancyItem.GetDouble("Deposit").ToString("N0", nfi)</div> } } </div> @foreach (LoopItem item in tenancyItem.GetLoop("Rents")) { <div class="table-row small"> @{ if (@item.GetDouble("Amount") > 0) { <div class="row-col-left boxwrapper">@item.GetValue("Name")</div> <div class="row-col-right">Kr. @item.GetDouble("Amount").ToString("N0", nfi)</div> } } </div> } @foreach (LoopItem txt in GetLoop("Texts")) { var headline = txt.GetString("Headline").Trim(); var text = txt.GetString("Text").Trim(); if (headline =="Udgifter ud over huslejen") { if(!string.IsNullOrEmpty(text)) { ////<pre>@text </pre> <div class="clearfix"></div> <div class="table-row small forbrug-box"> <div class="row-col-left">Forbrug:</div> <div class="forbrug-text">@text</div> </div> //<div class="row-col-left dot">@text</div> //<div class="row-col-right"></div> } } } <signup data-available="@tenancyItem.GetValue("InternetAvailable")" data-zipcity="@tenancyItem.GetValue("ZipCity")" data-tenancytype="@tenancyItem.GetValue("TenancyType")" data-companyno="@tenancyItem.GetValue("CompanyNo")" data-departmentno="@tenancyItem.GetValue("DepartmentNo")" data-tenancyno="@tenancyItem.GetValue("TenancyNo")" data-userstatus="@tenancyItem.GetValue("UserStatus")" data-updatemethod="reload" /> @* <div class="table-row green-bth ng-isolate-scope" data-updatemethod="reload" data-userstatus="@GetValue("EGTenancy.UserStatus")" data-tenancyno="@GetValue("EGTenancy.Tenancy.TenancyNo")" data-departmentno="@GetValue("EGDepartment.Department.DepartmentNo")" data-companyno="@GetValue("EGDepartment.CompanyNo")" data-tenancytype="@GetValue("EGTenancy.Tenancy.TenancyType")" data-zipcity="@GetValue("EGDepartment.Department.ZipCity")"> <a class="ng-binding" ng-click="showSignup()" title="Ja tak, skriv mig op" href="#" >Ja tak, skriv mig op</a> </div>*@ </div> </div> </div> <div class="col-sm-12 col-md-8 apartment-fakta"> <h3>Fakta for denne bolig</h3> <ul class="clearfix"> @{ foreach (FactItem factItem in facts) { <li> @*<pre>@husdyrText 00</pre>*@ <div class="icon"><span class="@factItem.IconClass"></span></div> <div class="left-txt"> <div class="fakta-sm-txt">@factItem.Heading</div> @if (factItem.MouseOver != "") { <div class="fakta-lg-txt pointer">@factItem.Text <span data-toggle="tooltip" data-placement="bottom" title="@factItem.MouseOver"><i class="show-tooltip icon-question-sign"></i></span> @* <i class="show-tooltip icon-question-sign"></i> <span class="tooltip-txt">@factItem.MouseOver <strong class="arrow-down">&nbsp;</strong> <i class="close-tooltip icon-remove-sign"></i> </span> *@ </div> } else { <div class="fakta-lg-txt">@factItem.Text</div> } </div> </li> } } </ul> <style> .smallView { -webkit-transform: scale(1.5); -moz-transform: scale(1.5); -o-transform: scale(1.5); -webkit-transition: all 2s linear; -moz-transition: all 2s linear; -o-transition: all 2s linear; cursor: -moz-zoom-out; cursor: -webkit-zoom-out; cursor: zoom-out; } .modal-dialog { margin-top: 130px; max-height: 100%; } .bigView { -webkit-transform: scale(1); -moz-transform: scale(1); -o-transform: scale(1); -webkit-transition: all 2s ease; -moz-transition: all 2s ease; -o-transition: all 2s ease; cursor: -moz-zoom-in; cursor: -webkit-zoom-in; cursor: zoom-in; } </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="facts-link white-btn"> <a href= "@departmentLink" title="Vis afdelingen">Vis afdelingen</a> <div class="modal fade" id="photo-modal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="bigView modal-content" onclick="$(this).toggleClass('smallView bigView');"> <a href="#" class="modal-close" data-dismiss="modal">&nbsp;</a> <div class="modal-body"> <div class="blueprint-gallery"> <ul class="bleuprint-list clearfix"> @{ var count = 0; foreach (LoopItem file in tenancyItem.GetLoop("Files")) { if (@file.GetValue("TypeName").ToString() == "EGBluePrint") ///"bluePrint" { printUrl = @file.GetValue("Path") + "/" + @file.GetValue("FileName"); } if (@file.GetValue("TypeName").ToString() == "EGBluePrint"){ <li> <img class="img-responsive" src="/admin/public/getImage.ashx?Image=@file.GetString("Path")/@file.GetString("FileName")&amp;Resolution=75&amp;Compression=70&amp;Width=800&amp;Height=auto" /> </li> count++; } } if (count == 0){ <li> <h4>There's no blueprints for this apartment.</h4> </li> } } </ul> </div> </div> </div> </div> </div> @*@if(count != 0){ <a class="vis-plantegning" title="Vis plantegning" data-toggle="modal" data-target="#photo-modal">Se vejl. plantegning</a> }*@ <a class="vis-plantegning" title="Vis plantegning" data-toggle="modal" data-target="#photo-modal">Se vejl. plantegning</a> </div> </div> </div> </div> <div class="points-of-interest"> <div class="container"> <div class="col-md-8 place-google"> <h3>Lejemålets afstande til...</h3> <div class="google-wrapper"> @{ // var coordinate = GetSstring(" Tenancies").FirstOrDefault(); if (tenancyItem.GetString("Coordinate.Lat") != "" && tenancyItem.GetString("Coordinate.Lat") != "") { HttpContext.Current.Items["lat"] = tenancyItem.GetString("Coordinate.Lat").Replace(",", "."); HttpContext.Current.Items["lng"] = tenancyItem.GetString("Coordinate.Lng").Replace(",", "."); @RenderItemList(new { ItemType = "Points_of_interest", ListSourceType = "Page", ListSourcePage = Base.ChkInteger(Pageview.Area.Item["PointsOfInterestPageID"].ToString().Replace("Default.aspx?ID=", "")), ItemFieldsList = "*", ListPageSize = 6, ListOrderBy = "Created", ListTemplate = "NemLejeV2/poi2.cshtml", IncludeParagraphItems = true }); var lat = GetString("EGTenancy.Coordinate.Lat").Replace(",", "."); var lng = GetString("EGTenancy.Coordinate.Lng").Replace(",", "."); } } </div> </div> </div> <div id="dummyMap"></div> </div> </div> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content modal-content-custom-vagtorning"> <div class="modal-header modal-header-custom-vagtorning"> <button type="button" class="close close-custom-vagtorning" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="info-notice-h4">Information</h4> </div> <div id="infonotice" class="modal-body"> @disclaimerText </div> <div class="modal-footer modal-footer-custom-vagtorning"> </div> </div> </div> </div>