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