Error compiling template "Designs/Martec/TemplateRenderer/StoreLocatorWithZipcode.cshtml"
Line 547: '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" ? "&Format=" + imageFormat : "";
53 string getImageCompression = imageCompression != 0 ? "&Compression=" + imageCompression : "";
54 string bgColor = !string.IsNullOrEmpty(background) ? "&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 = "&Width=" + getImageWidth;
72 }
73 if (getImageHeight != 0)
74 {
75 heightString = "&Height=" + getImageHeight;
76 }
77
78 string output = "/Admin/Public/GetImage.ashx?Image=" + sourceString + widthString + heightString + "&altFmImage_path=" + alternativeImage + getImageFormat + getImageCompression + "&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="mandatory col-sm-3 col-xs-12" name="tag_adr">
154 <label class="text-left" for="zipCode">@Translate("Zip Code")</label>
155 <input type="text" name="zip" id="zipCode" title="@Translate("Zip Code")" />
156 </fieldset>
157 <fieldset class="col-sm-3 col-xs-12" name="tag_dst">
158 <label class="text-left" for="radius">@Translate("Distance")</label>
159 <select id="radius" name="radius">
160 <option value="5">5 @Translate("miles")</option>
161 <option value="15">15 @Translate("miles")</option>
162 <option value="25">25 @Translate("miles")</option>
163 <option value="50">50 @Translate("miles")</option>
164 </select>
165 </fieldset>
166 <div class="locations-filter col-xs-12 col-sm-3">
167 <button class="btn btn-bg" data-filter-value="test">@Translate("search","Search")</button>
168 </div>
169 </div>
170
171 @SnippetStart("jsOnLoad")
172 onLoadMaps();
173 @SnippetEnd("jsOnLoad")
174 <div id="loading" class="col-xs-12"> </div>
175 <div class="map col-sm-8 col-xs-12 noPaddingLeft">
176 <div id="Maps-85-map"></div>
177 </div>
178 <div class="list col-sm-4 col-xs-12">
179 <div class="no-matches">@Translate("NoLocationsFound","No locations found")</div>
180 <ol class="storeList" id="Maps-85-list" data-sort-order="desc">
181 @foreach (System.Data.DataRow store in dataSet)
182 {
183 var regionTextList = dataRegionsSet.First(r => r["CountryTextRegionCode"].ToString() == store["AccessUserState"].ToString());
184 string regionTextString = regionTextList != null ? regionTextList["CountryTextName"].ToString() : "";
185
186 <li data-lat="@store["AccessUserGeoLocationLat"]" data-lng="@store["AccessUserGeoLocationLng"]" data-title="@store["AccessUserName"]"
187 data-filter-values="" data-country="@store["AccessUserCountry"]" data-citycode="@store["AccessUserState"]" data-city="@regionTextString" data-sort-value="@store["AccessUserName"]">
188 <div>
189
190 <b>@store["AccessUserName"]</b><br/>
191
192 @store["AccessUserAddress"]<br/>
193 @store["AccessUserCity"]
194 @if(!string.IsNullOrEmpty(store["AccessUserState"].ToString())) {
195 @:, @Dynamicweb.Ecommerce.International.CountryText.GetRegionTexts(store["AccessUserCountry"].ToString()).First(c => c.RegionCode == store["AccessUserState"].ToString()).Name
196 }
197 @store["AccessUserZip"]
198 </div>
199 </li>
200 }
201 </ol>
202
203 </div>
204 @SnippetStart("externalScripts")
205 <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
206 <script type="text/javascript" src="/Files/Templates/Designs/RizzoDesignFolder/Maps/javascripts/Maps.js"></script>
207 @SnippetEnd("externalScripts")
208
209
210 </div>