Exception in template (Designs\YellowBus-Mobile\ItemPublisher/Details/detailsPackTour.cshtml): System.ArgumentException: System name of the target item cannot be an empty string.
Parameter name: metadata
   at Dynamicweb.Content.Items.Queries.Repository..ctor(ItemType metadata)
   at Dynamicweb.Content.Items.Queries.StorageFactory.CreateRepository(ItemType metadata)
   at Dynamicweb.Content.Items.Queries.StorageManager.GetByPageId(String systemName, Int32 pageId, Boolean draft)
   at CompiledRazorTemplates.Dynamic.deecadaeebebff.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@using System @using System @using System.Collections.Generic @functions { public const string BOOKING_REGION_QSTR = "region"; public const string BOOKING_REGION_IDENTIFIER_ALIAS = "BookingLinkIdentifier"; public const string BOOKING_REGION_LINK_ALIAS = "BookingLink"; // Added - Tiago S. - Get all 'City' Items for the given Area. // Get all the 'City' items in the current area. public static IEnumerable<Dynamicweb.Content.Items.Item> getCityItemsForArea(int areaId) { return getItemsForArea(areaId, "City"); } // Get all the 'CityYBMobile' items in the current area. public static IEnumerable<Dynamicweb.Content.Items.Item> getCityItemsForMobileArea(int areaId) { return getItemsForArea(areaId, "CityYBMobile"); } // Get all the pages in the current area whcih are of the desired type. public static IEnumerable<Dynamicweb.Content.Items.Item> getItemsForArea(int areaId, string itemType) { return Dynamicweb.Content.Page.GetPagesByAreaID(areaId) // Filter by Item type: 'City' .Where(x => x.ItemType == itemType) // transform into Items .Select<Dynamicweb.Content.Page, Dynamicweb.Content.Items.Item>( x => Dynamicweb.Content.Items.ItemManager.Storage.GetById(x.ItemType, x.ItemId) ); } // Traverses the parent pages to obtain the RegionIdentifier from a 'City' page ancestor. public static string getRegionIdentifier(Dynamicweb.Content.Page currPage) { var auxPage = currPage; do { if (auxPage.ItemType == "City") { return getRegionIdentifier(auxPage.ItemType, auxPage.ItemId); } } while ((auxPage = auxPage.Parent) != null); return String.Empty; } public static string getRegionIdentifier(Dynamicweb.Frontend.Page currPage) { return getRegionIdentifier(Dynamicweb.Content.Page.GetPageById(currPage.ID)); } public static string getRegionIdentifier(string itemType, string itemId) { var cityPageItem = Dynamicweb.Content.Items.ItemManager.Storage.GetById(itemType, itemId); return (string) cityPageItem[BOOKING_REGION_IDENTIFIER_ALIAS]; } public static string getRegionIdentifier(int pageId) { using (var dbCon = Dynamicweb.Database.CreateConnection()) { string pageItemId = String.Empty; do { // Check the parent using (var cmd = dbCon.CreateCommand()) { cmd.CommandText = "SELECT PageItemType, PageParentPageId, PageItemId FROM Page WHERE PageId = ''+@pageId+''"; cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter() { ParameterName = "pageId", SqlDbType = System.Data.SqlDbType.Int, Value = pageId }); using (var reader = cmd.ExecuteReader()) { // No such oage found with the specified id. if (!reader.Read()) { break; } // the current page is of the desired type ('City'). if (reader.GetString(0) == "City") { pageItemId = reader.GetString(2); break; } // Parent page id. if (reader[1] == DBNull.Value) { pageId = -1; } else { pageId = reader.GetInt32(1); } } } } while (pageId >= 0); // 'City' page item was found. if (!String.IsNullOrEmpty(pageItemId)) { return getRegionIdentifier("City", pageItemId); } return null; } } } @{ var areaItem = Pageview.Area.Item; int desktopAreaID = areaItem["YellowBusID"] != null ? Convert.ToInt32(areaItem["YellowBusID"].ToString()) : Pageview.Area.ID; string str_zero = ""; string str_buyPageID = (areaItem["BuyPageID"] != null) ? areaItem["BuyPageID"].ToString() : ""; string str_globalLang = GetGlobalValue("Global:Area.Lang"); string str_nameTour = GetString("ItemPublisher:Item.Name"); string str_textTour = GetString("ItemPublisher:Item.Text.Value"); string str_title = ""; string str_image = ""; var loop_tour = GetLoop("ItemPublisher:Item.Offers"); string desc = GetString("ItemPublisher:Item.Discount"); string intPrice = GetString("ItemPublisher:Item.AdultsPrice"); string str_childrenPrice = GetString("ItemPublisher:Item.ChildrensPrice"); string str_packageId = GetString("ItemPublisher:Item.Field.Id"); string str_adultPrice = GetString("ItemPublisher:Item.AdultsPrice"); string str_bookingRouteId = GetString("ItemPublisher:Item.BookingRouteId"); bool bol_bookingDirect = GetBoolean("ItemPublisher:Item.BookingDirect"); if (GetGlobalValue("Global:Area.Lang") == "en") { str_adultPrice = str_adultPrice.Replace(",","."); str_childrenPrice = str_childrenPrice.Replace(",", "."); } double dbl_adultsPrice = Convert.ToDouble(str_adultPrice); string str_linkPage = areaItem["DetailPage"] != null ? areaItem["DetailPage"].ToString() : ""; double num_priceNumber; double dbl_priceAfterDiscount = Double.TryParse(GetString("ItemPublisher:Item.AdultsPrice"), out num_priceNumber) ? (dbl_adultsPrice - dbl_adultsPrice * (GetInteger("ItemPublisher:Item.Discount") / 100.00)) : 0; double dbl_childrensPriceAfterDiscount = 0; if (!string.IsNullOrEmpty(str_childrenPrice)) { dbl_childrensPriceAfterDiscount = Convert.ToDouble(str_childrenPrice); } // Added - Tiago S. - Booking Options // Get the list of booking options for this circuit. var bookingItems = GetLoop("ItemPublisher:Item.Booking").Where(x => x.GetBoolean("Item.Booking.Active")); // Added - Tiago S. - Get the 'Booking Region Url' from an ancestor 'City' type page. // Get the city Page Id. var cityPageId = (int)Dynamicweb.Database.ExecuteScalar( String.Format("SELECT PageParentPageID FROM Page WHERE PageItemId = {0} AND PageItemType like '%TourPackage%'", GetInteger("ItemPublisher:Item.Field.Id"))); // Region identifier. string bookingRegionIdentifier = getRegionIdentifier(Dynamicweb.Content.Page.GetPageById(cityPageId)); var tourWeather = GetString("ItemPublisher:Item.WeatherSourceCode"); var cityParent = (int)Dynamicweb.Database.ExecuteScalar( String.Format("SELECT PageParentPageID FROM Page WHERE PageId={0}", cityPageId)); if (string.IsNullOrEmpty(tourWeather)) { var cityPage = Dynamicweb.Content.Items.Item.GetItemsByPageId(cityParent); var cityPageFirst = cityPage.First(); object cityPageValue = null; cityPageFirst.TryGetValue("WeatherSourceCode", ref cityPageValue); tourWeather = cityPageValue.ToString(); } } <div class="tourInfo"> <h1> @str_nameTour </h1> @if (!string.IsNullOrEmpty(tourWeather)) { <div class="weatherInfoWrapper"> @tourWeather </div> <div class="clear"></div> } <hr class="hrbottom"> <p> @str_textTour </p> @if(loop_tour.Count > 1){ var allPages = Dynamicweb.Content.Page.GetPagesByAreaID(desktopAreaID); foreach(LoopItem i in loop_tour){ int int_relatedPageId = getCurrentLangPageId(new{ int_pageId = i.GetInteger("ItemPublisher:Item.Offers.Offer") },allPages); if(int_relatedPageId != 0) { var page = Dynamicweb.Content.Page.GetPageById(int_relatedPageId); if(page != null) { if(page.ItemType != "" && page.ItemId != ""){ Dynamicweb.Content.Items.Item tempItem = Dynamicweb.Content.Items.Item.GetItemById(page.ItemType, page.ItemId); if(tempItem != null) { string str_tourDetail = "/"+ str_linkPage + "&amp;packageId=" + str_packageId + "&amp;itemId=" + page.ItemType + ":" + page.ItemId; <div class="toursBoxListCircuit3"> <div class="picBox"> <a rel="nofollow" href="@str_tourDetail"> <figure><img src='/Admin/Public/GetImage.ashx?Image=@tempItem["MainImage"]&amp;Format=jpg&amp;Width=107&amp;Height=80&amp;Crop=0'/></figure> </a> </div> <h2 class="descTit16"><a rel="nofollow" href="@str_tourDetail"> @tempItem["Name"]</a></h2> <p class="descCircuit3"> @Truncate(tempItem["Text"].ToString(), 50)</p> <a class="triangleWhite" rel="nofollow" href="@str_tourDetail"> </a> <a class="triangleLink" rel="nofollow" href="@str_tourDetail"> <i class="fa fa-plus"></i></a> @if(i.Index != loop_tour.Count){ <a class="plusWhiteCircle"> <span class="plusBlueCircle"> <i class="fa fa-plus fa-2x"></i> </span> </a> } </div> } } } } } } <div class="purchaseBgTour2"> @* Ensure backwards compatibility - if there are no list items, we display the price information the old way. *@ @if (bookingItems == null || !bookingItems.Any()) { <span class="totValue"> Total:</span> <span class="priceValue"> @dbl_priceAfterDiscount.ToString("0.00")&euro;</span> <div class="rightContent"><span class="discountPrice"> @desc% </span> <span class="oldPrice"> @str_adultPrice </span></div> <hr class="hrtourSlider"> } @if (!bol_bookingDirect) { <form id="tourTicketsForm" name="tourTicketsForm" action="/Default.aspx" class='tourTicketsForm@((String.IsNullOrEmpty(str_bookingRouteId)) ? " inactive" : "" )'> <input type="hidden" name="Id" value="@str_buyPageID" /> <input type="hidden" name="locale" value="@str_globalLang" /> <input type="hidden" name="routeId" value="@str_bookingRouteId" /> @* Added - Tiago S. - take the specific region Identifier into account. *@ @* If a specific URL has been defined for this region, use it. *@ @if (!String.IsNullOrEmpty(bookingRegionIdentifier)) { <input type="hidden" name="@BOOKING_REGION_QSTR" value="@bookingRegionIdentifier" /> } @if(GetInteger("ItemPublisher:Item.ReleaseDays") != 0 || GetString("ItemPublisher:Item.TourBeginDate") != "" || GetString("ItemPublisher:Item.TourEndDate") != ""){ <fieldset id="tourReleaseDays" class="TextInput mandatory"> <label for="releaseDays" class="h4"> @Translate("YB_chooseDate")</label> <input type="text" name="arrive" id="releaseDays" class="calendarIcon" title='@Translate("YB_chooseDate")' /> <span> @Translate("YB_reservationsDisclaimer") @(GetInteger("ItemPublisher:Item.ReleaseDays") * 24)h @Translate("YB_reservationsDisclaimer2")</span> </fieldset> } @if(GetBoolean("ItemPublisher:Item.TourWithLunch")){ string str_titleWithout = GetString("ItemPublisher:Item.Usage") == "lunch" ? Translate("YB_tourWithoutLunchPriceTitle", "Circuito S/Almoço") : Translate("YB_tourWithoutDaysPriceTitle", "Circuito 1 Dia"); <h3 class="h4">@str_titleWithout</h3> } <fieldset id="tourTicketPrice" class="mandatory"> <select class="tourTicketPrice" name="adults"> <option value="default" >00</option> <option value="1" selected="selected">01</option> @for(int n = 2; n < 51; n++){ str_zero = n.ToString().Length == 2 ? "" : "0"; <option value="@n">@str_zero@n</option> } </select> <label> @Translate("YB_tourAdultsPriceLabel") x @dbl_priceAfterDiscount.ToString("0.00") &euro; </label> </fieldset> @if (dbl_childrensPriceAfterDiscount.ToString("0.00") != "0,00") { <fieldset id="childrensPriceHolder"> <select class="tourTicketChildrensPrice" name="children"> <option value="default" selected="selected">00</option> @for (int n = 1; n < 51; n++) { str_zero = n.ToString().Length == 2 ? "" : "0"; <option value="@n">@str_zero@n</option> } </select> <label class="childrens"> @Translate("YB_tourChildrensPriceLabel")x @dbl_childrensPriceAfterDiscount.ToString("0.00")&euro; <br /> ( @Translate("YB_tourChildrensDelimitation"))</label> </fieldset> } @if(GetBoolean("ItemPublisher:Item.TourWithLunch") && GetString("ItemPublisher:Item.AdultsLunchPrice") != ""){ string str_titleWith = GetString("ItemPublisher:Item.Usage") == "lunch" ? Translate("YB_tourWithLunchPriceTitle") : Translate("YB_tourWithDaysPriceTitle"); double dbl_adultsLunchPrice = GetGlobalValue("Global:Area.Lang") == "en" ? Convert.ToDouble(GetString("ItemPublisher:Item.AdultsLunchPrice").Replace(',', '.')) : GetDouble("ItemPublisher:Item.AdultsLunchPrice"); double dbl_lunchPriceAfterDiscount = Double.TryParse(GetString("ItemPublisher:Item.AdultsLunchPrice"), out num_priceNumber) ? (dbl_adultsLunchPrice - dbl_adultsLunchPrice * (GetInteger("ItemPublisher:Item.Discount") / 100.00)) : 0; <h3 class="h4" id="tourWithLunchTitle">@str_titleWith</h3> <fieldset id="tourLunchTicketPrice"> <select class="tourLunchTicketPrice" name="adultsLunch"> <option value="default">00</option> @for(int n = 1; n < 51; n++){ str_zero = n.ToString().Length == 2 ? "" : "0"; <option value="@n">@str_zero@n</option> } </select> <label>@Translate("YB_tourAdultsPriceLabel") x @dbl_lunchPriceAfterDiscount.ToString("0.00")&euro; </label> </fieldset> if(GetString("ItemPublisher:Item.ChildrensLunchPrice") != ""){ double dbl_childrensLunchPriceAfterDiscount = GetGlobalValue("Global:Area.Lang") == "en" ? Convert.ToDouble(GetString("ItemPublisher:Item.ChildrensLunchPrice").Replace(',', '.')) : GetDouble("ItemPublisher:Item.ChildrensLunchPrice"); <fieldset id="childrensLunchPriceHolder"> <select class="tourLunchTicketChildrensPrice" name="childrenLunch"> <option value="default" selected="selected">00</option> @for(int n = 1; n < 51; n++){ str_zero = n.ToString().Length == 2 ? "" : "0"; <option value="@n">@str_zero@n</option> } </select> <label class="childrens"> @Translate("YB_tourChildrensPriceLabel") x @dbl_childrensLunchPriceAfterDiscount.ToString("0.00")&euro; <br/> ( @Translate("YB_tourChildrensDelimitation"))</label> </fieldset> } } <div class="formButtons"> @if (!GetBoolean("ItemPublisher:Item.Unavailable")) { <input class="navbtResultados" type="submit" value='@Translate("YBM_buyNow")'/> } else{ <input type="submit" class="navbtResultados" disabled value='@Translate("YB_Unavailable", "Indisponível")' /> } @if(GetString("ItemPublisher:Item.Disclaimer") != ""){<br/><span>@GetString("ItemPublisher:Item.Disclaimer")</span>}</div> </form> }else{ @* Backwards Compatibility - list items override the default behaviour *@ if (bookingItems == null || !bookingItems.Any()) { <form action="/Default.aspx"> <input type="hidden" name="Id" value="@str_buyPageID"/> <input type="hidden" name="locale" value="@str_globalLang"/> <input type="hidden" name="book-direct" value="@str_bookingRouteId"/> @* Added - Tiago S. - take the specific region Identifier into account. *@ @* If a specific URL has been defined for this region, use it. *@ @if (!String.IsNullOrEmpty(bookingRegionIdentifier)) { <input type="hidden" name="@BOOKING_REGION_QSTR" value="@bookingRegionIdentifier"/> } <div class="formButtons"> @if (!GetBoolean("ItemPublisher:Item.Unavailable")) { <input class="navbtResultados" type="submit" value='@Translate("YBM_buyNow")'/> } else{ <input type="submit" class="navbtResultados" disabled value='@Translate("YB_Unavailable", "Indisponível")' /> } @if (GetString("ItemPublisher:Item.Disclaimer") != "") { <br/> <span>@GetString("ItemPublisher:Item.Disclaimer")</span> } </div> </form> } if (bookingItems != null) { @* Booking Button List *@ foreach (var item in bookingItems) { string btnText = item.GetString("ItemPublisher:Item.Booking.ButtonText"), bookingOptHeading = item.GetString("ItemPublisher:Item.Booking.Heading"), bookingOptPriceStr = item.GetString("ItemPublisher:Item.Booking.Price"), bookingRouteId = item.GetString("ItemPublisher:Item.Booking.BookingID"); if (!item.GetBoolean("ItemPublisher:Item.Booking.Active")) { continue; } // If no text is defined, use the default translate value. if (String.IsNullOrEmpty(btnText)) { btnText = Translate("YBM_buyNow"); } @*<div class="bookingOpt"> <span class="totValue"> @Translate("YBM_totalPrice")</span> <span class="priceValue"> @dbl_priceAfterDiscount.ToString("0.00")&euro; </span> <div class="rightContent"><span class="discountPrice"> @desc% </span> <span class="oldPrice"> @str_adultPrice &euro; </span> </div> <form action="/Default.aspx"> <input type="hidden" name="Id" value="@str_buyPageID"/> <input type="hidden" name="locale" value="@str_globalLang"/> <input type="hidden" name="book-direct" value="@bookingRouteId"/> $1$ Added - Tiago S. - take the specific region Identifier into account. #1# $1$ If a specific URL has been defined for this region, use it. #1# @if (!String.IsNullOrEmpty(bookingRegionIdentifier)) { <input type="hidden" name="@BOOKING_REGION_QSTR" value="@bookingRegionIdentifier" /> } <div class="formButtons"> <input type="submit" class="navbtResultados" value='@btnText'/> @if (item.GetString("ItemPublisher:Item.Booking.Disclaimer") != "") { <br/><span>@item.GetString("ItemPublisher:Item.Booking.Disclaimer")</span> } </div> </form> </div>*@ <div class="bookingOpt"> @* Booking Option Heading *@ @if (!String.IsNullOrEmpty(bookingOptHeading)) { <div class="bookingOptionHeading"> @bookingOptHeading </div> } @* Booking Option Price *@ @if (!String.IsNullOrEmpty(bookingOptPriceStr) && !String.IsNullOrWhiteSpace(bookingOptPriceStr)) { int bookingOptDiscount = item.GetInteger("ItemPublisher:Item.Booking.Discount"); double bookingOptPrice; double bookingOptPriceAfterDiscount = Double.TryParse(bookingOptPriceStr, out bookingOptPrice) ? (bookingOptPrice - bookingOptPrice * (bookingOptDiscount / 100.00)) : 0; <div class="bookingOptionPriceContainer"> <span class="totValue"> @Translate("YBM_totalPrice")</span> <span class="priceValue"> @bookingOptPriceAfterDiscount.ToString("0.00")&euro; </span> @if (bookingOptDiscount != 0) { <div class="rightContent"> <span class="discountPrice"> @bookingOptDiscount% </span> <span class="oldPrice"> @bookingOptPrice &euro; </span> </div> } </div> } <form action="/Default.aspx"> <input type="hidden" name="Id" value="@str_buyPageID"/> <input type="hidden" name="locale" value="@str_globalLang"/> <input type="hidden" name="book-direct" value="@bookingRouteId"/> @* Added - Tiago S. - take the specific region Identifier into account. *@ @* If a specific URL has been defined for this region, use it. *@ @if (!String.IsNullOrEmpty(bookingRegionIdentifier)) { <input type="hidden" name="@BOOKING_REGION_QSTR" value="@bookingRegionIdentifier"/> } <div class="formButtons"> <input type="submit" class="navbtResultados" value='@btnText'/> @if (item.GetString("ItemPublisher:Item.Booking.Disclaimer") != "") { <br/><span>@item.GetString("ItemPublisher:Item.Booking.Disclaimer")</span> } </div> </form> </div> } } } </div> <!--@SnippetStart(jsVariables)--> var obj_tourPackageDetails = { str_adultsPrice: '@GetString("ItemPublisher:Item.AdultsPrice")', str_adultsLunchPrice: '@GetString("ItemPublisher:Item.AdultsLunchPrice")', str_childrensPrice: '@GetString("ItemPublisher:Item.ChildrensPrice")', str_childrensLunchPrice: '@GetString("ItemPublisher:Item.ChildrensLunchPrice")', str_discount: '@GetInteger("ItemPublisher:Item.Discount")', str_tourBeginDate: '@FormatDate(GetString("ItemPublisher:Item.TourBeginDate"))', str_tourEndDate: '@FormatDate(GetString("ItemPublisher:Item.TourEndDate"))', str_releaseDays: '@GetInteger("ItemPublisher:Item.ReleaseDays")', str_participantsMin: '@GetInteger("ItemPublisher:Item.ParticipantsMin")', str_participantsMax: '@GetInteger("ItemPublisher:Item.ParticipantsMax")', str_participantsError: 'Esta viagem tem um número de participantes mínimo/máximo. Confira o número de bilhetes. ' } var obj_tourDetails = obj_tourPackageDetails; <!--@SnippetEnd(jsVariables)--> @SnippetStart("jsOnLoad") onLoadTourPackages(); @SnippetEnd("jsOnLoad") @helper Truncate(string str_input,int num_length) { if(str_input.Length <= num_length){ @str_input }else{ @str_input.Substring(0,num_length)<text>...</text> } } @helper FormatDate(string str_date) { if(!String.IsNullOrEmpty(str_date)){ DateTime dat_date = Convert.ToDateTime(str_date); DateTime dat_newDate = new DateTime(dat_date.Year, dat_date.Month, dat_date.Day); @dat_newDate.ToString("yyyy'/'MM'/'dd"); }else{ string str_empty = "0"; @str_empty } } @functions { public int getCurrentLangPageId(dynamic obj_options, Dynamicweb.Content.PageCollection allCurrentPages) { int int_output = obj_options.int_pageId; if (obj_options.int_pageId > 0) { var currentPage = Dynamicweb.Content.Page.GetPageById(obj_options.int_pageId); if (currentPage != null) { if (currentPage.IsMaster) { int int_masterPageID = obj_options.int_pageId; var outputPage = allCurrentPages.Where(x => x.MasterPageID == int_masterPageID || (x.IsMaster && x.ID == int_masterPageID)); if (outputPage.Count() > 0) { int_output = (outputPage.FirstOrDefault().ID != null) ? outputPage.FirstOrDefault().ID : 0; } } else { int_output = obj_options.int_pageId; } } } return int_output; } }