Find a dealer

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