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