Find a dealer

Find a dealer
Error compiling template "Designs/Martec/TemplateRenderer/StoreLocator.cshtml"
Line 498: 'Dynamicweb.Ecommerce.International.CountryText' does not contain a definition for 'GetRegionTexts'

1 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 2 @using Dynamicweb.Ecommerce.International 3 @using Dynamicweb.Content 4 @using Dynamicweb.Rendering 5 @{ 6 Dynamicweb.Content.Items.Item itemArea = Pageview.Area.Item; 7 int generalSettingsPageId = Int32.Parse(itemArea["GeneralSettings"].ToString()); 8 9 10 var page = 115; //Dynamicweb.Extensibility.ServiceLocator.Current.GetPageService().GetPage(generalSettingsPageId); 11 Dynamicweb.Content.Items.Item generalSettings = Dynamicweb.Content.Items.Item.GetItemById("GeneralSettings","1"); 12 @helper CountrySelect(System.Collections.Generic.List<String> countriesList, Dictionary<string, string> countriesNames){ 13 <label class="text-left">@Translate("selectYourCountry", "Select your country:")</label> 14 <select name="country"> 15 <option selected="selected" value="">@Translate("all", "All")</option> 16 @RenderSnippet("US") 17 @foreach (string countryCode in countriesList.OrderBy(s => s)) 18 { 19 string countryStrip = countriesNames.ContainsKey(countryCode) ? countriesNames[countryCode] : countryCode; 20 if (countryCode == "US") 21 { 22 @SnippetStart("USA") 23 <option value="@countryCode">@countryStrip</option> 24 @SnippetEnd("USA") 25 } 26 else if (countryCode == "CA") 27 { 28 @SnippetStart("CAN") 29 <option value="@countryCode">@countryStrip</option> 30 @SnippetEnd("CAN") 31 } 32 <option value="@countryCode">@countryStrip</option> 33 } 34 </select> 35 } 36 37 @helper RegionSelect(){ 38 <label class="text-left">@Translate("selectYourRegion","Select your region:")</label> 39 <select data-width="100%" name="locality"> 40 <option value="">@Translate("all","All")</option> 41 </select> 42 } 43 } 44 @{ string designName = GetString("Template:DesignBaseUrl").Replace("/Files/Templates/Designs/", "").Replace("/", "");}@functions{ 45 public static string GetImage(string sourceString, int imageWidth, int imageHeight, int imageWidthTablet = 0, int imageHeightTablet = 0, int imageWidthMobile = 0, int imageHeightMobile = 0, string imageFormat = "jpg", int imageCompression = 0, int imageCrop = 5, string background = "", string designName = "Martec") 46 { 47 Dynamicweb.Frontend.PageView currentPageview = Dynamicweb.Frontend.PageView.Current(); 48 string currDevice = currentPageview.Device.ToString(); 49 string alternativeImage = !String.IsNullOrEmpty(currentPageview.Area.Item["NoImage"].ToString()) ? currentPageview.Area.Item["NoImage"].ToString() : "/Files/Templates/Designs/"+ designName + "/images/alternativeImage.jpg"; 50 string widthString = ""; 51 string heightString = ""; 52 string getImageFormat = imageFormat != "jpg" ? "&amp;Format=" + imageFormat : ""; 53 string getImageCompression = imageCompression != 0 ? "&amp;Compression=" + imageCompression : ""; 54 string bgColor = !string.IsNullOrEmpty(background) ? "&amp;Background="+background : ""; 55 int getImageWidth = imageWidth != 0 ? imageWidth : 0; 56 int getImageHeight = imageHeight != 0 ? imageHeight : 0; 57 58 if (currDevice == Dynamicweb.Frontend.Devices.DeviceType.Tablet.ToString()) 59 { 60 getImageWidth = imageWidthTablet != 0 ? imageWidthTablet : getImageWidth; 61 getImageHeight = imageHeightTablet != 0 ? imageHeightTablet : getImageHeight; 62 } 63 else if (currDevice == Dynamicweb.Frontend.Devices.DeviceType.Mobile.ToString()) 64 { 65 getImageWidth = imageWidthMobile != 0 ? imageWidthMobile : getImageWidth; 66 getImageHeight = imageHeightMobile != 0 ? imageHeightMobile : getImageHeight; 67 } 68 69 if (getImageWidth != 0) 70 { 71 widthString = "&amp;Width=" + getImageWidth; 72 } 73 if (getImageHeight != 0) 74 { 75 heightString = "&amp;Height=" + getImageHeight; 76 } 77 78 string output = "/Admin/Public/GetImage.ashx?Image=" + sourceString + widthString + heightString + "&amp;altFmImage_path=" + alternativeImage + getImageFormat + getImageCompression + "&amp;Crop=" + imageCrop + bgColor; 79 return output; 80 } 81 } 82 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 83 @using Dynamicweb.Rendering; 84 @using System; 85 @using System.Web; 86 @using System.Collections.Specialized; 87 88 @{ 89 string dealerGroups = generalSettings["DealerGroups"].ToString(); 90 string storesGroupID = !string.IsNullOrWhiteSpace(dealerGroups) ? "%" + dealerGroups + "%" : ""; 91 string accessDataSql = "SELECT AccessUserState, AccessUserCountry, AccessUserZip, AccessUserAddress, AccessUserName, AccessUserCity, AccessUserGeoLocationLat, AccessUserImage, AccessUserGeoLocationLng FROM accessUser WHERE AccessUserCountry is not NULL AND AccessUserCountry != '' AND AccessUserGeoLocationLat IS NOT NULL AND AccessUserGroups LIKE '" + storesGroupID + "'"; 92 string accessRegionsDataSql = "SELECT CountryTextName, CountryTextCode2, CountryTextRegionCode FROM EcomCountryText"; 93 string regionsString = "{"; 94 string country = ""; 95 string state = ""; 96 string countryLogged = !string.IsNullOrEmpty(HttpContext.Current.Request.Params["country"]) ? HttpContext.Current.Request.Params["country"] : country; 97 string stateLogged = !string.IsNullOrEmpty(HttpContext.Current.Request.Params["state"]) ? HttpContext.Current.Request.Params["state"] : state; 98 System.Data.DataRow[] dataSet = Dynamicweb.Data.Database.CreateDataSet(accessDataSql).Tables[0].Select(); 99 System.Data.DataRow[] dataRegionsSet = Dynamicweb.Data.Database.CreateDataSet(accessRegionsDataSql).Tables[0].Select(); 100 bool userIsLoggedIn = Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn(); 101 System.Collections.Generic.List<String> countriesList = dataSet.Select(r => ((string)r["AccessUserCountry"].ToString()).Trim() ).Distinct().ToList(); 102 Dictionary<string, string> countriesNames = new Dictionary<string, string>(); 103 104 foreach(System.Data.DataRow r in dataRegionsSet.Where(x => string.IsNullOrWhiteSpace(x["CountryTextRegionCode"].ToString()))) 105 { 106 if(!countriesNames.ContainsKey(r["CountryTextCode2"].ToString())) { 107 countriesNames.Add(r["CountryTextCode2"].ToString(), r["CountryTextName"].ToString()); 108 } 109 } 110 111 if(countryLogged != country) 112 { 113 stateLogged = ""; 114 } 115 116 if (userIsLoggedIn) 117 { 118 var user = Pageview.User; 119 countryLogged = user.Country.ToString(); 120 stateLogged = user.State.ToString(); 121 } 122 123 foreach (string i in countriesList) 124 { 125 System.Collections.Generic.List<String> regions = dataSet.Where(r => (string)r["AccessUserCountry"] == i).Select(r => ((string)r["AccessUserState"]).Trim() ).Distinct().ToList(); 126 int countNum = 0; 127 string countryStrip = i; 128 129 if(regionsString != "{") { 130 regionsString += ","; 131 } 132 regionsString += "\""+countryStrip+"\":["; 133 foreach (string region in regions){ 134 var regionTextList = !string.IsNullOrEmpty(region) ? dataRegionsSet.First(r => r["CountryTextRegionCode"].ToString() == region.ToString()) : null; 135 string regionText = regionTextList != null ? regionTextList["CountryTextName"].ToString() : ""; 136 137 if(!string.IsNullOrWhiteSpace(regionText)) 138 { 139 if(countNum != 0) { 140 regionsString += ","; 141 } 142 regionsString += "\""+@regionText+"\""; 143 countNum++; 144 } 145 } 146 regionsString += "]"; 147 148 } 149 regionsString += "}"; 150 } 151 <div class="dynamicweb-map" id="Maps-85" data-list-position="hidden"> 152 <div class="col-xs-12" id="findStoreFilter"> 153 <fieldset class="col-sm-3 col-xs-12 noPaddingLeft"> 154 @CountrySelect(countriesList, countriesNames) 155 </fieldset> 156 <fieldset class="col-sm-3 col-xs-12 regions"> 157 @RegionSelect() 158 </fieldset> 159 </div> 160 161 @SnippetStart("jsVariables") 162 var obj_loginLocation = { 163 str_country : "@countryLogged", 164 str_state : "@stateLogged" 165 } 166 @SnippetEnd("jsVariables") 167 @SnippetStart("jsOnLoad") 168 onLoadStoreLocator('@regionsString'); 169 @SnippetEnd("jsOnLoad") 170 <div class="locations-filter hide"> 171 <button data-filter-value="test"></button> 172 </div> 173 <div id="loading" class="col-xs-12">&nbsp;</div> 174 <div class="map col-sm-8 col-xs-12 noPaddingLeft"> 175 <div id="Maps-85-map"></div> 176 </div> 177 <div class="list col-sm-4 col-xs-12"> 178 <div class="no-matches">@Translate("NoLocationsFound","No locations found")</div> 179 <ol class="storeList" id="Maps-85-list" data-sort-order="desc"> 180 @foreach (System.Data.DataRow store in dataSet) 181 { 182 var regionTextList = dataRegionsSet.First(r => r["CountryTextRegionCode"].ToString() == store["AccessUserState"].ToString()); 183 string regionTextString = regionTextList != null ? regionTextList["CountryTextName"].ToString() : ""; 184 185 <li data-lat="@store["AccessUserGeoLocationLat"]" data-lng="@store["AccessUserGeoLocationLng"]" data-title="@store["AccessUserName"]" 186 data-filter-values="" data-country="@store["AccessUserCountry"]" data-citycode="@store["AccessUserState"]" data-city="@regionTextString" data-sort-value="@store["AccessUserName"]"> 187 <div> 188 189 <b>@store["AccessUserName"]</b><br/> 190 191 @store["AccessUserAddress"]<br/> 192 @store["AccessUserCity"] 193 @if(!string.IsNullOrEmpty(store["AccessUserState"].ToString())) { 194 @:, @Dynamicweb.Ecommerce.International.CountryText.GetRegionTexts(store["AccessUserCountry"].ToString()).First(c => c.RegionCode == store["AccessUserState"].ToString()).Name 195 } 196 @store["AccessUserZip"] 197 </div> 198 </li> 199 } 200 </ol> 201 202 </div> 203 @SnippetStart("externalScripts") 204 <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?v=3&amp;sensor=false"></script> 205 <script type="text/javascript" src="/Files/Templates/Designs/RizzoDesignFolder/Maps/javascripts/Maps.js"></script> 206 @SnippetEnd("externalScripts") 207 208 209 </div>