Exception in template (NemlejeV2/Tenancy2.cshtml): System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at CompiledRazorTemplates.Dynamic.deebbadbbcce.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 <!--MODULE--> <div class="container-fluid apartment-detail"> @{ LoopItem tenancyItem = GetLoop("Tenancies").First(); 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 GetLoop("Premises")) { 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 = "Lejemålstype", Text = tenancyItem.GetString("TenancyTypeName"), MouseOver = "", IconClass = "house" }); 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" }); var petsallow = ""; var husdyrText = ""; if (texts.ContainsKey("Husdyr")) { husdyrText = texts["Husdyr"].ToString(); if (texts["Husdyr"].ToString().StartsWith("Husdyr ikke")) /// "Nej" { petsallow = "Nej"; } else { petsallow = "Ja"; } } 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"; if (premises.ContainsKey("Altan")) { balcony = "Ja"; } facts.Add(new FactItem() { Heading = "Altan", Text = balcony, MouseOver = "", IconClass = "altan" }); var 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("Udhus")) { facts.Add(new FactItem() { Heading = "Udhus", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Hems")) { facts.Add(new FactItem() { Heading = "Hems", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Carport")) { facts.Add(new FactItem() { Heading = "Carport", Text = "Ja", MouseOver = "", IconClass = "garage" }); } if (premises.ContainsKey("Loft-/kælderrum")) { facts.Add(new FactItem() { Heading = "Loft-/kælderrum", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Fællesvaskeri")) { facts.Add(new FactItem() { Heading = "Fællesvaskeri", Text = "Ja", MouseOver = "", IconClass = "laundry" }); } if (premises.ContainsKey("Varmepumpe")) { facts.Add(new FactItem() { Heading = "Varmepumpe", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Udestue")) { facts.Add(new FactItem() { Heading = "Udestue", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Handicapkøkken")) { facts.Add(new FactItem() { Heading = "Handicapkøkken", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Vand i leje")) { facts.Add(new FactItem() { Heading = "Vand i leje", Text = "Ja", MouseOver = "", IconClass = "info" }); } if (premises.ContainsKey("Fælles gårdanl.")) { facts.Add(new FactItem() { Heading = "Fælles gårdanl.", Text = "Ja", 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); } } if (listOfFiles.Count == 0) { 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("TenancySelect").ToString() == "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 container" data-ride="carousel"> <!-- Indicators --> <ol class="carousel-indicators"> @{ 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 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/NoApartmentPicture.jpg&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/NoApartmentPicture.jpg&amp;AlternativeImage=/files/templates/designs/bleau-solutionset/img/NoApartmentPicture.jpg&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"> <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"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> } } <div class="app-info"> <p class="ellipsis ellip">@tenancyItem.GetString("Address")</p> <p class="ellipsis ellip">@tenancyItem.GetString("ZipCity")</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">Husleje <span class="small">pr. mdr.</span></div> <div class="row-col-right">Kr. @tenancyItem.GetDouble("RentGross").ToString("N0", nfi)</div> } } </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">@item.GetValue("Name")</div> <div class="row-col-right">Kr. @item.GetDouble("Amount").ToString("N0", nfi)</div> } } </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</h3> <ul class="clearfix"> @{ foreach (FactItem factItem in facts) { <li> <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<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> <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="modal-content"> <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") { printUrl = @file.GetValue("Path") + "/" + @file.GetValue("FileName"); } if (@file.GetValue("TypeName").ToString() == "EGBluePrint") { <li> <img src="/admin/public/getImage.ashx?Image=@file.GetString("Path")/@file.GetString("FileName")&amp;Resolution=75&amp;Compression=70&amp;Width=500&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 title="Vis plantegning" data-toggle="modal" data-target="#photo-modal">Vis 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>