Error compiling template "Designs/PacificBag/TemplateRenderer/StoreLocatorWithZipcode.cshtml"
Line 582: '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" ? "&Format=" + imageFormat : "";
51 string getImageCompression = imageCompression != 0 ? "&Compression=" + imageCompression : "";
52 string bgColor = !string.IsNullOrEmpty(background) ? "&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 = "&Width=" + getImageWidth;
70 }
71 if (getImageHeight != 0)
72 {
73 heightString = "&Height=" + getImageHeight;
74 }
75
76 string output = "/Admin/Public/GetImage.ashx?Image=" + sourceString + widthString + heightString + "&altFmImage_path=" + alternativeImage + getImageFormat + getImageCompression + "&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" ? "&Format=" + imageFormat : "";
88 string getImageCompression = imageCompression != 0 ? "&Compression=" + imageCompression : "";
89 string bgColor = !string.IsNullOrEmpty(background) ? "&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 = "&Width=" + getImageWidth;
107 }
108 if (getImageHeight != 0)
109 {
110 heightString = "&Height=" + getImageHeight;
111 }
112
113 string output = "/Admin/Public/GetImage.ashx?Image=" + sourceString + widthString + heightString + "&altFmImage_path=" + alternativeImage + getImageFormat + getImageCompression + "&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="mandatory col-sm-3 col-xs-12" name="tag_adr">
189 <label class="text-left" for="zipCode">@Translate("Zip Code")</label>
190 <input type="text" name="zip" id="zipCode" title="@Translate("Zip Code")" />
191 </fieldset>
192 <fieldset class="col-sm-3 col-xs-12" name="tag_dst">
193 <label class="text-left" for="radius">@Translate("Distance")</label>
194 <select id="radius" name="radius">
195 <option value="5">5 @Translate("miles")</option>
196 <option value="15">15 @Translate("miles")</option>
197 <option value="25">25 @Translate("miles")</option>
198 <option value="50">50 @Translate("miles")</option>
199 </select>
200 </fieldset>
201 <div class="locations-filter col-xs-12 col-sm-3">
202 <button class="btn btn-bg" data-filter-value="test">@Translate("search","Search")</button>
203 </div>
204 </div>
205
206 @SnippetStart("jsOnLoad")
207 onLoadMaps();
208 @SnippetEnd("jsOnLoad")
209 <div id="loading" class="col-xs-12"> </div>
210 <div class="map col-sm-8 col-xs-12 noPaddingLeft">
211 <div id="Maps-85-map"></div>
212 </div>
213 <div class="list col-sm-4 col-xs-12">
214 <div class="no-matches">@Translate("NoLocationsFound","No locations found")</div>
215 <ol class="storeList" id="Maps-85-list" data-sort-order="desc">
216 @foreach (System.Data.DataRow store in dataSet)
217 {
218 var regionTextList = dataRegionsSet.First(r => r["CountryTextRegionCode"].ToString() == store["AccessUserState"].ToString());
219 string regionTextString = regionTextList != null ? regionTextList["CountryTextName"].ToString() : "";
220
221 <li data-lat="@store["AccessUserGeoLocationLat"]" data-lng="@store["AccessUserGeoLocationLng"]" data-title="@store["AccessUserName"]"
222 data-filter-values="" data-country="@store["AccessUserCountry"]" data-citycode="@store["AccessUserState"]" data-city="@regionTextString" data-sort-value="@store["AccessUserName"]">
223 <div>
224
225 <b>@store["AccessUserName"]</b><br/>
226
227 @store["AccessUserAddress"]<br/>
228 @store["AccessUserCity"]
229 @if(!string.IsNullOrEmpty(store["AccessUserState"].ToString())) {
230 @:, @Dynamicweb.Ecommerce.International.CountryText.GetRegionTexts(store["AccessUserCountry"].ToString()).First(c => c.RegionCode == store["AccessUserState"].ToString()).Name
231 }
232 @store["AccessUserZip"]
233 </div>
234 </li>
235 }
236 </ol>
237
238 </div>
239 @SnippetStart("externalScripts")
240 <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
241 <script type="text/javascript" src="/Files/Templates/Designs/RizzoDesignFolder/Maps/javascripts/Maps.js"></script>
242 @SnippetEnd("externalScripts")
243
244
245 </div>