)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » TrekController (Ia.TentPlay.Wa.Controllers)

Public general use code classes and xml files that we've compiled and used over the years:

    1: using Microsoft.AspNetCore.Mvc;
    2: using Microsoft.AspNetCore.Mvc.Rendering;
    3: using System.Diagnostics;
    4: using System.Net;
    5: using System.Text;
    6: using System.Text.RegularExpressions;
    7:  
    8: namespace Ia.TentPlay.Wa.Controllers
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     ///
   14:     /// </summary>
   15:     /// 
   16:     /// <remarks> 
   17:     /// Copyright � 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   18:     ///
   19:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   20:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   21:     ///
   22:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   23:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   24:     /// 
   25:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   26:     /// 
   27:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   28:     /// </remarks> 
   29:     public partial class TrekController : Controller
   30:     {
   31:         private Ia.TentPlay.Wa.Models.TrekViewModel trek = new Ia.TentPlay.Wa.Models.TrekViewModel();
   32:  
   33:         private readonly ILogger<TrekController> _logger;
   34:  
   35:         /////////////////////////////////////////////////////////////////////////////////
   36:  
   37:         /// <summary>
   38:         ///
   39:         /// </summary>
   40:         public TrekController(ILogger<TrekController> logger)
   41:         {
   42:             _logger = logger;
   43:         }
   44:  
   45:         /////////////////////////////////////////////////////////////////////////////////
   46:  
   47:         /// <summary>
   48:         ///
   49:         /// </summary>
   50:         public IActionResult Index()
   51:         {
   52:             Page_DataBind();
   53:  
   54:             return View("Views/Trek/Index.cshtml", trek);
   55:         }
   56:  
   57:         /////////////////////////////////////////////////////////////////////////////////
   58:  
   59:         /// <summary>
   60:         ///
   61:         /// </summary>
   62:         public IActionResult FeatureDesignationCommand(string commandName)
   63:         {
   64:             var result = new Ia.Cl.Models.Result();
   65:  
   66:             if (commandName == "WriteFromXmlToDatabase")
   67:             {
   68:                 Ia.TentPlay.Cl.Models.Data.Trek.Default.WriteFeatureDesignationRecordListXmlToDatabase(out result);
   69:             }
   70:             else if (commandName == "Read")
   71:             {
   72:  
   73:                 trek.FeatureDesignationList = Ia.TentPlay.Cl.Models.Data.Trek.FeatureDesignation.ListFromDatabase(out result).OrderBy(i => i.Id).ToList();
   74:             }
   75:             else if (commandName == "Delete")
   76:             {
   77:                 Ia.TentPlay.Cl.Models.Data.Trek.Default.DeleteFeatureDesignationRecordListFromDatabase(out result);
   78:             }
   79:  
   80:             trek.FeatureDesignationResult = result;
   81:  
   82:             Page_DataBind();
   83:  
   84:             return View("Views/Trek/Index.cshtml", trek);
   85:         }
   86:  
   87:         /////////////////////////////////////////////////////////////////////////////////
   88:  
   89:         /// <summary>
   90:         ///
   91:         /// </summary>
   92:         [HttpPost]
   93:         public IActionResult FeatureCommand(string commandName, string countrySelect, string downloadedCountrySelect)
   94:         {
   95:             string fileCountry;
   96:             Ia.Cl.Models.Result result;
   97:             Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country applicationCountry;
   98:             Ia.Cl.Models.Country country;
   99:  
  100:             result = new Ia.Cl.Models.Result();
  101:  
  102:             if (commandName == "DeleteTruncateTableFromDatabase")
  103:             {
  104:                 Ia.TentPlay.Cl.Models.Data.Trek.Feature.DeleteTruncateTableFromDatabase(out result);
  105:             }
  106:             else
  107:             {
  108:                 fileCountry = countrySelect.ToLower();
  109:  
  110:                 country = (from c in Ia.Cl.Models.Country.List where c.Iso3 == fileCountry.ToUpper() select c).SingleOrDefault();
  111:  
  112:                 if (country != null)
  113:                 {
  114:                     if (commandName == "DownloadAndUnzipAndInsertIntoDatabase")
  115:                     {
  116:                         Ia.TentPlay.Cl.Models.Data.Trek.Feature.DownloadAndUnzipAndInsertIntoDatabase(country, out result);
  117:                     }
  118:                     else
  119:                     {
  120:                         fileCountry = downloadedCountrySelect.ToLower();
  121:  
  122:                         country = (from c in Ia.Cl.Models.Country.List where c.Iso3 == fileCountry.ToUpper() select c).SingleOrDefault();
  123:  
  124:                         if (commandName == "DeleteSpecificFromDatabase" || commandName == "ReadSpecificFromDatabase")
  125:                         {
  126:                             if (commandName == "DeleteSpecificFromDatabase")
  127:                             {
  128:                                 Ia.TentPlay.Cl.Models.Data.Trek.Feature.Delete(country, out result);
  129:                             }
  130:                             else if (commandName == "ReadSpecificFromDatabase")
  131:                             {
  132:                                 trek.FeatureList = Ia.TentPlay.Cl.Models.Data.Trek.Feature.List(country, 1000, out result);
  133:                             }
  134:                         }
  135:                         else
  136:                         {
  137:                             applicationCountry = (from c in Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.CountryList where c.Iso3 == fileCountry.ToUpper() select c).SingleOrDefault();
  138:  
  139:                             if (applicationCountry != null)
  140:                             {
  141:                                 Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.CountryStatisticCalcucation(ref applicationCountry);
  142:  
  143:                                 if (commandName == "GenerateSpecificSqliteDatabaseFile")
  144:                                 {
  145:                                     Ia.TentPlay.Cl.Models.Data.Trek.Default.GenerateSpecificFeatureSqliteDatabaseFileFromSqlServer(applicationCountry, out result);
  146:                                 }
  147:                                 else if (commandName == "DownloadSpecificSqliteDatabaseFile")
  148:                                 {
  149:                                     Ia.TentPlay.Cl.Models.Data.Trek.Default.DownloadSpecificFeatureSqliteDatabaseFileFromTempFolder(applicationCountry, out result);
  150:                                 }
  151:                                 else if (commandName == "GenerateDrawableVersionOfNavigationViewBackground")
  152:                                 {
  153:                                     Ia.TentPlay.Cl.Models.Data.Trek.Default.GenerateDrawableVersionOfNavigationViewBackground(applicationCountry, out result);
  154:                                 }
  155:                                 else if (commandName == "DownloadSpecificDrawableImages")
  156:                                 {
  157:                                     Ia.TentPlay.Cl.Models.Data.Trek.Default.DownloadSpecificDrawableImageFileFromTempFolder(applicationCountry, out result);
  158:                                 }
  159:                                 else if (commandName == "PrepareAndroidApplicationFiles")
  160:                                 {
  161:                                     PrepareAndroidApplicationFiles(applicationCountry, out result);
  162:                                 }
  163:                                 else
  164:                                 {
  165:                                     throw new Exception("commandName invalid or unknown. ");
  166:                                 }
  167:                             }
  168:                             else
  169:                             {
  170:                                 result.AddError(@"The country """ + country.Name + @""" is not ready in the application country list XML file in the Trek project. ");
  171:                             }
  172:                         }
  173:                     }
  174:                 }
  175:                 else
  176:                 {
  177:                     result.AddError(@"Country with iso2 = """ + fileCountry + @""" is not in the country list. ");
  178:                 }
  179:             }
  180:  
  181:             trek.FeatureResult = result;
  182:  
  183:             Page_DataBind();
  184:  
  185:             return View("Views/Trek/Index.cshtml", trek);
  186:         }
  187:  
  188:         ////////////////////////////////////////////////////////////////////////////
  189:  
  190:         /// <summary>
  191:         ///
  192:         /// </summary>
  193:         public IActionResult MiscellaneousOnCommand(string commandName)
  194:         {
  195:             string s;
  196:             StringBuilder stringBuilder;
  197:             Ia.Cl.Models.Result result;
  198:             List<Ia.Cl.Models.Country> countryList;
  199:  
  200:             stringBuilder = new StringBuilder();
  201:             result = new Ia.Cl.Models.Result();
  202:  
  203:             if (commandName == "GenerateWebSitemapSiteMapNodeListOfAllCountries")
  204:             {
  205:                 trek.MiscellaneousResult.AddSuccess(Ia.TentPlay.Cl.Models.Ui.Trek.Default.WebSitemapSiteMapNodeListOfAllCountriesInStringFormat());
  206:             }
  207:             else
  208:             {
  209:             }
  210:  
  211:             Page_DataBind();
  212:  
  213:             return View("Views/Trek/Index.cshtml", trek);
  214:         }
  215:  
  216:         ////////////////////////////////////////////////////////////////////////////
  217:  
  218:         /// <summary>
  219:         /// 
  220:         /// </summary>
  221:         private void GenerateDistanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesListIntoViewState(Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country applicationCountry, out Ia.Cl.Models.Result result)
  222:         {
  223:             string s;
  224:             List<long> distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList;
  225:  
  226:             result = new Ia.Cl.Models.Result();
  227:  
  228:             distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList = Ia.TentPlay.Cl.Models.Data.Trek.Feature.DistanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList(applicationCountry.Iso3, Ia.TentPlay.Cl.Models.Business.Trek.Default.MaximumNumberOfTrekToDisplayNearTheCapital);
  229:  
  230:             if (distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList != null)
  231:             {
  232:                 if (distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList.Count == 512)
  233:                 {
  234:                     ViewBag["distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList"] = distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList;
  235:  
  236:                     result.AddSuccess("distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList generated and stored into ViewState. ");
  237:                 }
  238:                 else
  239:                 {
  240:                     ViewBag["distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList"] = null;
  241:  
  242:                     result.AddError(@"distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList length is not 512, its " + distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList.Count + ". ViewState was nulled. ");
  243:                 }
  244:             }
  245:             else
  246:             {
  247:                 ViewBag["distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList"] = null;
  248:  
  249:                 result.AddError(@"distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList is null. ViewState was nulled. ");
  250:             }
  251:         }
  252:  
  253:         ////////////////////////////////////////////////////////////////////////////
  254:  
  255:         /// <summary>
  256:         /// 
  257:         /// </summary>
  258:         private void PrepareAndroidApplicationFiles(Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country applicationCountry, out Ia.Cl.Models.Result result)
  259:         {
  260:             List<long> distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList;
  261:             string fileCountry, applicationLanguageListString, applicationLanguageIso6391ListString, s, longDescription, manifestPackage;
  262:             Match match;
  263:             StringBuilder stringBuilder;
  264:  
  265:             applicationLanguageListString = string.Join(", ", (from c in applicationCountry.Languages select c.EnglishName).ToArray());
  266:             applicationLanguageIso6391ListString = string.Join(",", (from c in applicationCountry.Languages select c.Symbol).ToArray());
  267:  
  268:             stringBuilder = new StringBuilder();
  269:  
  270:             result = new Ia.Cl.Models.Result();
  271:  
  272:             GenerateDistanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesListIntoViewState(applicationCountry, out result);
  273:  
  274:             if (applicationCountry.LanguageListMatchesTranslationList)
  275:             {
  276:                 //if (applicationCountry.ManifestPackage.Contains(applicationCountry.ManifestPackagePrefix + "." + applicationCountry.Iso3))
  277:                 //{
  278:                 if (!string.IsNullOrEmpty(applicationCountry.GoogleMapsDebugApiKey) && !string.IsNullOrEmpty(applicationCountry.GoogleAdMobAdUnitDebugId) && !string.IsNullOrEmpty(applicationCountry.GoogleAdMobAppId) && !string.IsNullOrEmpty(applicationCountry.GoogleMapsProductionApiKey) && !string.IsNullOrEmpty(applicationCountry.GoogleAdMobAdUnitProductionId))
  279:                 {
  280:                     if (true) // if all languages within country 
  281:                     {
  282:                         distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList = (List<long>)ViewBag["distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList"];
  283:  
  284:                         if (distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList != null)
  285:                         {
  286:                             // general
  287:                             s = @"
  288: Information about and steps to setup " + applicationCountry.ApplicationNameDictionary["en"] + @" country application:
  289:  
  290: Application Information:
  291: - Name: " + applicationCountry.ApplicationNameDictionary["en"] + @"
  292: - Play Store: " + applicationCountry.ApplicationUrl + @"
  293: - Version name: """ + applicationCountry.VersionName + @"""
  294: - Whats new: """ + applicationCountry.WhatsNew + @"""
  295: - Spoken language(s): " + applicationLanguageListString + @"
  296:  
  297: Steps:
  298: - In Trek/app/src/main/AndroidManifest.xml/manifest:
  299:     - Setup manifest/versionName = " + applicationCountry.VersionName + @", and versionCode = " + Ia.TentPlay.Cl.Models.Business.Default.VersionCode + @".
  300:     - Set manifest/application/supportsRtl = ""false"" for non-Arabic, and non-Hebrew.
  301:     - Set manifest/application/intent-filter/data/pathPattern=""/trek/country/" + applicationCountry.Iso3 + @"""
  302:  
  303: - Make sure you have the following restValues in app/build.gradle buildTypes:
  304:  
  305: buildTypes {
  306:     debug {
  307:         resValue ""string"", ""google_maps_api_key"", """ + applicationCountry.GoogleMapsDebugApiKey + @"""
  308:         resValue ""string"", ""google_admob_app_id"", """ + applicationCountry.GoogleAdMobAppId + @"""
  309:         resValue ""string"", ""google_admob_ad_unit_id"", """ + applicationCountry.GoogleAdMobAdUnitDebugId + @"""
  310:     }
  311:  
  312:     release {
  313:         resValue ""string"", ""google_maps_api_key"", """ + applicationCountry.GoogleMapsProductionApiKey + @"""
  314:         resValue ""string"", ""google_admob_app_id"", """ + applicationCountry.GoogleAdMobAppId + @"""
  315:         resValue ""string"", ""google_admob_ad_unit_id"", """ + applicationCountry.GoogleAdMobAdUnitProductionId + @"""
  316:     }
  317: }
  318: ";
  319:  
  320:                             stringBuilder.Append(s);
  321:  
  322:  
  323:                             // language specific Store Listing texts
  324:  
  325:                             s = @"
  326: Store listings by language:
  327: ";
  328:                             stringBuilder.Append(s);
  329:  
  330:                             foreach (Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Translation translation in applicationCountry.Translations)
  331:                             {
  332:                                 s = @"
  333: - Language: " + (from l in applicationCountry.Languages where l.Iso6391 == translation.Iso6391 select l.EnglishName).Single() + @":
  334: - Application name: " + applicationCountry.ApplicationNameDictionary[translation.Iso6391] + @"
  335: - Short description: " + (from t in applicationCountry.Translations where t.Iso6391 == translation.Iso6391 select t.ShortDescription).Single() + @"
  336: - Long description: " + (from t in applicationCountry.Translations where t.Iso6391 == translation.Iso6391 select t.LongDescription).Single() + @"
  337: ";
  338:  
  339:                                 stringBuilder.Append(s);
  340:                             }
  341:  
  342:  
  343:                             // language specific Android XML files:
  344:  
  345:                             foreach (Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Translation translation in applicationCountry.Translations)
  346:                             {
  347:                                 //longDescription = applicationCountry.LongDescription;
  348:                                 //ReplaceNameVariableWithName(ref longDescription, applicationCountry);
  349:                                 // - Short description: """ + applicationCountry.ShortDescription + @"""
  350:                                 // - Long description: """ + longDescription + @"""
  351:  
  352:                                 if (translation.Iso6391 == "en")
  353:                                 {
  354:                                     s = @"
  355: - Copy the following strings into app\src\main\res\values\strings.xml:
  356: <resources>
  357: " + FormatTranslationSpecificStringResourceStrings(applicationCountry, translation) +
  358:                 @"
  359:     <string name=""application_version_copyright_year"" translatable=""false"">" + applicationCountry.CopyrightYear + @"</string>
  360:     <string name=""company_name"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.CompanyName + @"</string>
  361:     <string name=""company_email"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.CompanyEmail + @"</string>
  362:     <string name=""company_url"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.CompanyUrl + @"</string>
  363:     <string name=""application_company_name"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.ApplicationCompanyName + @"</string>
  364:     <string name=""application_company_email"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.ApplicationCompanyEmail + @"</string>
  365:     <string name=""application_company_url"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.ApplicationCompanyUrl + @"</string>
  366:     <string name=""facebook_profile_url"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.FacebookProfileUrl + @"</string>
  367:     <string name=""facebook_profile_id"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.FacebookProfileId + @"</string>
  368:     <string name=""instagram_user_name"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.InstagramUserName + @"</string>
  369:     <string name=""twitter_user_name"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.TwitterUserName + @"</string>
  370:     <string name=""pinterest_user_name"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Data.CompanyInformation.PinterestUserName + @"</string>
  371:     <string name=""manifest_package_prefix"" translatable=""false"">" + applicationCountry.ManifestPackagePrefix + @"</string>
  372:     <string name=""manifest_package"" translatable=""false"">" + applicationCountry.ManifestPackage + @"</string>
  373:     <string name=""application_url"" translatable=""false"">" + applicationCountry.ApplicationUrl + @"</string>
  374:     <string name=""sqlite_database_file_name"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Business.Trek.Default.SqliteDatabaseFileName(applicationCountry.Iso3, applicationCountry.VersionName) + @"</string>
  375:     <string name=""application_country_iso2"" translatable=""false"">" + applicationCountry.Iso3 + @"</string>
  376:     <string name=""application_language_iso6391_list"" translatable=""false"">" + applicationLanguageIso6391ListString + @"</string>
  377:  
  378:     <string name=""maximum_number_of_trek_to_display_near_the_capital"" translatable=""false"">" + Ia.TentPlay.Cl.Models.Business.Trek.Default.MaximumNumberOfTrekToDisplayNearTheCapital + @"</string>
  379:     <string name=""distance_to_capital_of_the_nth_furthest_trek_according_to_binary_selected_classes_list"" translatable=""false"">" + string.Join(",", distanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList) + @"</string>
  380:  
  381:     <string name=""feature_count"" translatable=""false"">" + applicationCountry.FeatureCount + @"</string>
  382:     <string name=""administrative_feature_count"" translatable=""false"">" + applicationCountry.AdministrativeFeatureCount + @"</string>
  383:     <string name=""populated_feature_count"" translatable=""false"">" + applicationCountry.PopulatedFeatureCount + @"</string>
  384:     <string name=""vegetation_feature_count"" translatable=""false"">" + applicationCountry.VegetationFeatureCount + @"</string>
  385:     <string name=""locality_feature_count"" translatable=""false"">" + applicationCountry.LocalityFeatureCount + @"</string>
  386:     <string name=""undersea_feature_count"" translatable=""false"">" + applicationCountry.UnderseaFeatureCount + @"</string>
  387:     <string name=""street_feature_count"" translatable=""false"">" + applicationCountry.StreetFeatureCount + @"</string>
  388:     <string name=""hypsographic_feature_count"" translatable=""false"">" + applicationCountry.HypsographicFeatureCount + @"</string>
  389:     <string name=""hydrographic_feature_count"" translatable=""false"">" + applicationCountry.HydrographicFeatureCount + @"</string>
  390:     <string name=""spot_feature_count"" translatable=""false"">" + applicationCountry.SpotFeatureCount + @"</string>
  391:  
  392: " + FormatCountryImageStringResourceStrings(applicationCountry.NavigationHeaderImages) +
  393:                 @"
  394:     <string name=""navigation_drawer_open"" translatable=""false"">Open</string>
  395:     <string name=""navigation_drawer_close"" translatable=""false"">Close</string>
  396: </resources>
  397:  
  398: ";
  399:                                 }
  400:                                 else
  401:                                 {
  402:                                     s = @"
  403: - Copy the following strings into app\src\main\res\values-" + ConvertIso6391ToAndroidValueFolderExtention(translation.Iso6391) + @"\strings.xml:
  404: <resources>
  405: " + FormatTranslationSpecificStringResourceStrings(applicationCountry, translation) + @"</resources>
  406:  
  407: ";
  408:                                 }
  409:  
  410:                                 stringBuilder.Append(s);
  411:                             }
  412:  
  413:                             // colors and theme
  414:                             s = @"
  415:  
  416: - Make sure you delete unrelated string.xml files of other apps.
  417:  
  418: - Update app\src\main\res\values\colors.xml:
  419: <resources>
  420:     <color name=""colorPrimary"">" + applicationCountry.ColorPrimary + @"</color>
  421:     <color name=""colorPrimaryDark"">" + applicationCountry.ColorPrimaryDark + @"</color>
  422:     <color name=""colorAccent"">" + applicationCountry.ColorAccent + @"</color>
  423:  
  424:     <color name=""colorOrange"">#E89404</color>
  425:     <color name=""colorYellowOrange"">#FFDC36</color>
  426:     <color name=""colorRed"">#DA6161</color>
  427:     <color name=""colorWhileSmoke"">#F7EFE7</color>
  428:     <color name=""colorDeepBlue"">#1A8DFF</color>
  429:     <color name=""colorLightGreen"">#D6E7CE</color>
  430:     <color name=""colorDarkGreen"">#5EE517</color>
  431:     <color name=""colorLightBlue"">#A5CFFF</color>
  432:     <color name=""colorPurple"">#757FFF</color>
  433:     <color name=""colorLightYellow"">#FFEDB1</color>
  434:     <color name=""colorLightOrange"">#FFDB9C</color>
  435:     <color name=""colorBlack"">#000000</color>
  436:     <color name=""colorWhite"">#FFFFFF</color>
  437:     <color name=""colorStreet"">#494848</color>
  438:  
  439:     <color name=""A"">@color/colorYellowOrange</color>
  440:     <color name=""P"">@color/colorLightOrange</color>
  441:     <color name=""V"">@color/colorDarkGreen</color>
  442:     <color name=""L"">@color/colorOrange</color>
  443:     <color name=""U"">@color/colorDeepBlue</color>
  444:     <color name=""R"">@color/colorStreet</color>
  445:     <color name=""T"">@color/colorLightOrange</color>
  446:     <color name=""H"">@color/colorLightBlue</color>
  447:     <color name=""S"">@color/colorRed</color>
  448: </resources>
  449: ";
  450:                             stringBuilder.Append(s);
  451:  
  452:                             s = stringBuilder.ToString();
  453:  
  454:                             s = s.Replace("'", "&#39;"); // use &#39; instead of &apos; to work 
  455:                             s = s.Replace("<", "&lt;");
  456:                             s = s.Replace(">", "&gt;");
  457:                             s = s.Replace(" & ", " &amp;amp; ");
  458:  
  459:                             s = "<pre>" + s + "</pre>";
  460:  
  461:                             result.AddSuccess(s);
  462:                         }
  463:                         else
  464:                         {
  465:                             result.AddError(@"DistanceToCapitalOfTheNthFurthestTrekAccordingToBinarySelectedClassesList from ViewState is null. You should generate it first. ");
  466:                         }
  467:                     }
  468:                     else
  469:                     {
  470:                         result.AddError(@"Languages ... ");
  471:                     }
  472:                 }
  473:                 else
  474:                 {
  475:                     result.AddError(@"googleMapsDebugApiKey, googleAdMobAdUnitDebugId, googleAdMobAppId, googleMapsProductionApiKey, and/or googleAdMobAdUnitProductionId is missing from the application-information.xml file. ");
  476:                 }
  477:                 //}
  478:                 //else
  479:                 //{
  480:                 //    result.AddError(@"There is an inconsistency between manifest package prefix, manifest package name, and country Iso3. ManifestPackagePrefix: " + applicationCountry.ManifestPackagePrefix + @", ManifestPackage: " + applicationCountry.ManifestPackage + @", Iso3: " + applicationCountry.Iso3);
  481:                 //}
  482:             }
  483:             else
  484:             {
  485:                 result.AddError(@"The country language list of """ + applicationCountry.Name + @""" and available application country translation XML list do not match (" + applicationLanguageListString + " (" + applicationLanguageIso6391ListString + "))");
  486:             }
  487:         }
  488:  
  489:         ////////////////////////////////////////////////////////////////////////////
  490:  
  491:         /// <summary>
  492:         /// 
  493:         /// </summary>
  494:         private string ConvertIso6391ToAndroidValueFolderExtention(string Iso6391)
  495:         {
  496:             string e;
  497:  
  498:             if (Iso6391 == "zh_simplified") e = "zh-rCN"; // China, HongKong, Macau and Singapore
  499:             else if (Iso6391 == "zh_traditional") e = "zh-rTW"; // traditional chinese in HongKong, Macau and Taiwan
  500:             else e = Iso6391;
  501:  
  502:             return e;
  503:         }
  504:  
  505:         ////////////////////////////////////////////////////////////////////////////
  506:  
  507:         /// <summary>
  508:         /// 
  509:         /// </summary>
  510:         private string FormatTranslationSpecificStringResourceStrings(Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country applicationCountry, Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Translation translation)
  511:         {
  512:             int numberOfStringVersions;
  513:             string s;
  514:             StringBuilder stringBuilder;
  515:             Ia.Cl.Models.Result result;
  516:             List<Ia.TentPlay.Cl.Models.Business.Trek.FeatureClass> featureClassNameAndCountList;
  517:             List<Ia.TentPlay.Cl.Models.Business.Trek.FeatureDesignation> featureDesignationNameAndCountList;
  518:  
  519:             numberOfStringVersions = 7;
  520:             stringBuilder = new StringBuilder();
  521:  
  522:             if (translation != null)
  523:             {
  524:                 featureClassNameAndCountList = Ia.TentPlay.Cl.Models.Data.Trek.Default.FeatureClassNameAndCountWithinDatabaseList(applicationCountry.Iso3, translation, out result);
  525:                 featureDesignationNameAndCountList = Ia.TentPlay.Cl.Models.Data.Trek.Default.FeatureDesignationNameAndCountWithinDatabaseList(applicationCountry.Iso3, translation, out result);
  526:  
  527:                 FormatStringBuilderString(ref stringBuilder, "ApplicationName", applicationCountry.ApplicationNameDictionary[translation.Iso6391], true);
  528:                 FormatStringBuilderString(ref stringBuilder, "ApplicationShortDescription", translation.ShortDescription, true);
  529:                 FormatStringBuilderString(ref stringBuilder, "ApplicationLongDescription", translation.LongDescription, true);
  530:  
  531:                 FormatStringBuilderString(ref stringBuilder, "SiteName", translation.SiteName, true);
  532:                 //FormatStringBuilderString(ref stringBuilder, "CompanyName", translation.CompanyName, true);
  533:                 FormatStringBuilderString(ref stringBuilder, "AboutTitle", translation.AboutTitle, true);
  534:                 FormatStringBuilderString(ref stringBuilder, "AboutTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.AboutTitle), true);
  535:  
  536:                 FormatStringBuilderString(ref stringBuilder, "AboutCount", numberOfStringVersions.ToString(), true);
  537:  
  538:                 for (int i = 0; i < numberOfStringVersions; i++)
  539:                 {
  540:                     s = Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.BuildRandomDesignationListString(featureDesignationNameAndCountList);
  541:                     s = translation.About.Replace("#randomDesignationList", s);
  542:  
  543:                     FormatStringBuilderString(ref stringBuilder, "About_" + i, s, true);
  544:                 }
  545:  
  546:                 FormatStringBuilderString(ref stringBuilder, "SearchSearchHint", translation.SearchSearchHint, true);
  547:  
  548:                 FormatStringBuilderString(ref stringBuilder, "StatisticTitle", translation.StatisticTitle, true);
  549:                 FormatStringBuilderString(ref stringBuilder, "StatisticTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.StatisticTitle), true);
  550:                 FormatStringBuilderString(ref stringBuilder, "Statistic", translation.Statistic, true);
  551:  
  552:                 foreach (var fc in featureClassNameAndCountList)
  553:                 {
  554:                     s = string.Join(", ", (from f in featureDesignationNameAndCountList where f.FeatureClass == fc.Id orderby f.Name select f.Name + " (" + f.Count + ")").ToArray());
  555:  
  556:                     FormatStringBuilderString(ref stringBuilder, "Statistic" + fc.Name + "ClassFeatureDesignation", s, true);
  557:                 }
  558:  
  559:                 FormatStringBuilderString(ref stringBuilder, "SettingTitle", translation.SettingTitle, true);
  560:                 FormatStringBuilderString(ref stringBuilder, "SettingTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.SettingTitle), true);
  561:                 FormatStringBuilderString(ref stringBuilder, "Setting", translation.Setting, true);
  562:  
  563:                 FormatStringBuilderString(ref stringBuilder, "ShareTitle", translation.ShareTitle, true);
  564:                 FormatStringBuilderString(ref stringBuilder, "ShareTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.ShareTitle), true);
  565:                 FormatStringBuilderString(ref stringBuilder, "ShareApplication", translation.ShareApplication, true);
  566:                 FormatStringBuilderString(ref stringBuilder, "ShareTrek", translation.ShareTrek, true);
  567:                 FormatStringBuilderString(ref stringBuilder, "ShareNoEmailClientInstalled", translation.ShareNoEmailClientInstalled, true);
  568:                 FormatStringBuilderString(ref stringBuilder, "ShareContactUs", translation.ShareContactUs, true);
  569:  
  570:                 FormatStringBuilderString(ref stringBuilder, "HelpFeedbackTitle", translation.HelpFeedbackTitle, true);
  571:                 FormatStringBuilderString(ref stringBuilder, "HelpFeedbackTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.HelpFeedbackTitle), true);
  572:                 FormatStringBuilderString(ref stringBuilder, "HelpTitle", translation.HelpTitle, true);
  573:                 FormatStringBuilderString(ref stringBuilder, "HelpTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.HelpTitle), true);
  574:                 FormatStringBuilderString(ref stringBuilder, "HelpMagnifiyingGlass", translation.HelpMagnifiyingGlass, true);
  575:                 FormatStringBuilderString(ref stringBuilder, "HelpMainListOrder", translation.HelpMainListOrder, true);
  576:                 FormatStringBuilderString(ref stringBuilder, "HelpMapType", translation.HelpMapType, true);
  577:                 FormatStringBuilderString(ref stringBuilder, "HelpGoogleMapRoute", translation.HelpGoogleMapRoute, true);
  578:                 FormatStringBuilderString(ref stringBuilder, "HelpGoogleMapMarker", translation.HelpGoogleMapMarker, true);
  579:                 FormatStringBuilderString(ref stringBuilder, "Help", translation.Help, true);
  580:                 FormatStringBuilderString(ref stringBuilder, "FeedbackTitle", translation.FeedbackTitle, true);
  581:                 FormatStringBuilderString(ref stringBuilder, "FeedbackTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.FeedbackTitle), true);
  582:                 FormatStringBuilderString(ref stringBuilder, "FeedbackEmailSubject", translation.FeedbackEmailSubject, true);
  583:                 FormatStringBuilderString(ref stringBuilder, "Feedback", translation.Feedback, true);
  584:  
  585:                 FormatStringBuilderString(ref stringBuilder, "LegalTitle", translation.LegalTitle, true);
  586:                 FormatStringBuilderString(ref stringBuilder, "LegalTitleCaseTitle", Ia.Cl.Models.Default.ToTitleCase(translation.LegalTitle), true);
  587:                 FormatStringBuilderString(ref stringBuilder, "Legal", translation.Legal, true);
  588:  
  589:  
  590:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassName", translation.FeatureClassName, true);
  591:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassCaption", translation.FeatureClassCaption, true);
  592:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassDescription", translation.FeatureClassDescription, true);
  593:  
  594:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassAdministrativeName", translation.FeatureClassAdministrativeName, true);
  595:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassAdministrativeCaption", translation.FeatureClassAdministrativeCaption, true);
  596:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassAdministrativeDescription", translation.FeatureClassAdministrativeDescription, true);
  597:  
  598:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassPopulatedName", translation.FeatureClassPopulatedName, true);
  599:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassPopulatedCaption", translation.FeatureClassPopulatedCaption, true);
  600:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassPopulatedDescription", translation.FeatureClassPopulatedDescription, true);
  601:  
  602:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassVegetationName", translation.FeatureClassVegetationName, true);
  603:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassVegetationCaption", translation.FeatureClassVegetationCaption, true);
  604:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassVegetationDescription", translation.FeatureClassVegetationDescription, true);
  605:  
  606:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassLocalityName", translation.FeatureClassLocalityName, true);
  607:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassLocalityCaption", translation.FeatureClassLocalityCaption, true);
  608:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassLocalityDescription", translation.FeatureClassLocalityDescription, true);
  609:  
  610:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassUnderseaName", translation.FeatureClassUnderseaName, true);
  611:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassUnderseaCaption", translation.FeatureClassUnderseaCaption, true);
  612:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassUnderseaDescription", translation.FeatureClassUnderseaDescription, true);
  613:  
  614:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassStreetName", translation.FeatureClassStreetName, true);
  615:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassStreetCaption", translation.FeatureClassStreetCaption, true);
  616:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassStreetDescription", translation.FeatureClassStreetDescription, true);
  617:  
  618:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassHypsographicName", translation.FeatureClassHypsographicName, true);
  619:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassHypsographicCaption", translation.FeatureClassHypsographicCaption, true);
  620:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassHypsographicDescription", translation.FeatureClassHypsographicDescription, true);
  621:  
  622:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassHydrographicName", translation.FeatureClassHydrographicName, true);
  623:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassHydrographicCaption", translation.FeatureClassHydrographicCaption, true);
  624:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassHydrographicDescription", translation.FeatureClassHydrographicDescription, true);
  625:  
  626:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassSpotName", translation.FeatureClassSpotName, true);
  627:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassSpotCaption", translation.FeatureClassSpotCaption, true);
  628:                 FormatStringBuilderString(ref stringBuilder, "FeatureClassSpotDescription", translation.FeatureClassSpotDescription, true);
  629:             }
  630:             else
  631:             {
  632:                 throw new Exception("translation = null");
  633:             }
  634:  
  635:             return stringBuilder.ToString();
  636:         }
  637:  
  638:         ////////////////////////////////////////////////////////////////////////////
  639:  
  640:         /// <summary>
  641:         /// 
  642:         /// </summary>
  643:         private string FormatCountryImageStringResourceStrings(List<Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Image> imageList)
  644:         {
  645:             int i;
  646:             StringBuilder stringBuilder;
  647:  
  648:             stringBuilder = new StringBuilder();
  649:  
  650:             if (imageList != null)
  651:             {
  652:                 i = 0; // important to start from zero
  653:  
  654:                 FormatStringBuilderString(ref stringBuilder, "NavigationHeaderImageCount", imageList.Count.ToString(), false);
  655:  
  656:                 foreach (Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Image im in imageList)
  657:                 {
  658:                     //FormatStringBuilderString(ref stringBuilder, "NavigationHeaderImageCaption_" + i, im.Caption);
  659:                     //FormatStringBuilderString(ref stringBuilder, "NavigationHeaderImagePhotographer_" + i, im.Photographer);
  660:                     //FormatStringBuilderString(ref stringBuilder, "NavigationHeaderImageSource_" + i, im.Source);
  661:                     FormatStringBuilderString(ref stringBuilder, "NavigationHeaderImageFileName_" + i, im.AndroidFileName, false);
  662:  
  663:                     i++;
  664:                 }
  665:             }
  666:  
  667:             return stringBuilder.ToString();
  668:         }
  669:  
  670:         ////////////////////////////////////////////////////////////////////////////
  671:  
  672:         /// <summary>
  673:         /// 
  674:         /// </summary>
  675:         private void FormatStringBuilderString(ref StringBuilder stringBuilder, string classPropertyName, string classPropertyValue, bool IsTranslatable)
  676:         {
  677:             if (IsTranslatable) stringBuilder.AppendLine(@"    <string name=""" + Ia.Cl.Models.Default.CapsDelimitedToUnderscoreLowercase(classPropertyName) + @""">" + FormatTextInAndroidStringFriendlyFormat(classPropertyValue) + @"</string>");
  678:             else stringBuilder.AppendLine(@"    <string name=""" + Ia.Cl.Models.Default.CapsDelimitedToUnderscoreLowercase(classPropertyName) + @""" translatable=""false"">" + FormatTextInAndroidStringFriendlyFormat(classPropertyValue) + @"</string>");
  679:         }
  680:  
  681:         ////////////////////////////////////////////////////////////////////////////
  682:  
  683:         /// <summary>
  684:         /// 
  685:         /// </summary>
  686:         private string FormatTextInAndroidStringFriendlyFormat(string s)
  687:         {
  688:             Regex trim = new Regex(@"\s\s+");
  689:  
  690:             if (!string.IsNullOrEmpty(s))
  691:             {
  692:                 // order important
  693:                 s = s.Replace("'", "\\'"); // replace "'" with "\'" string
  694:                 s = s.Replace("\r\n", "\\n");
  695:                 s = s.Replace("\n", "\\n");
  696:                 s = trim.Replace(s, " ");
  697:                 s = s.Replace("\\n ", "\\n");
  698:             }
  699:  
  700:             return s;
  701:         }
  702:  
  703:         ////////////////////////////////////////////////////////////////////////////
  704:  
  705:         /// <summary>
  706:         /// 
  707:         /// </summary>
  708:         private void Page_DataBind()
  709:         {
  710:             var list = Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.CountryList;
  711:  
  712:             trek.ApplicationCountryListLabel = string.Join(", ", list.OrderBy(u => u.Name).Select(u => u.Name).ToList());
  713:  
  714:             CountryDropDownList_DataBind();
  715:             DownloadedCountryDropDownList_DataBind();
  716:         }
  717:  
  718:         ////////////////////////////////////////////////////////////////////////////
  719:  
  720:         /// <summary>
  721:         /// 
  722:         /// </summary>
  723:         private void CountryDropDownList_DataBind()
  724:         {
  725:             var list = Ia.Cl.Models.Country.List.OrderBy(u => u.Name).ToList();
  726:  
  727:             trek.CountrySelectList = new SelectList(list, "Iso3", "Name");
  728:  
  729:             /*
  730:             var index = countryDropDownList.SelectedIndex;
  731: 
  732:             var countryList = Ia.Cl.Models.Country.List;
  733: 
  734:             var gns = Ia.TentPlay.Cl.Model.Data.Trek.Default.GnsCountryCodeList;
  735: 
  736:             countryList = countryList.Where(u => gns.Contains(u.Iso3)).ToList();
  737: 
  738:             countryDropDownList.DataSource = countryList.OrderBy(u => u.Name);
  739: 
  740:             countryDropDownList.DataTextField = "Name";
  741:             countryDropDownList.DataValueField = "Iso3";
  742: 
  743:             countryDropDownList.DataBind();
  744: 
  745:             if (countryDropDownList.Items.Count > 0) countryDropDownList.SelectedIndex = (index < countryDropDownList.Items.Count) ? index : 0;
  746:             */
  747:  
  748:         }
  749:  
  750:         ////////////////////////////////////////////////////////////////////////////
  751:  
  752:         /// <summary>
  753:         /// 
  754:         /// </summary>
  755:         private void DownloadedCountryDropDownList_DataBind()
  756:         {
  757:             //trek.DownloadedCountryDropDownList = Ia.Cl.Models.Country.List.OrderBy(u => u.Name).ToList();
  758:  
  759:             //int index;
  760:             Dictionary<string, string> dictionary;
  761:  
  762:             dictionary = new Dictionary<string, string>();
  763:  
  764:             //index = downloadedCountryDropDownList.SelectedIndex;
  765:  
  766:             dictionary = Ia.TentPlay.Cl.Models.Data.Trek.Feature.DistinctFileCountryWithCountList();//.DistinctFileCountryList();
  767:  
  768:             if (dictionary.Count > 0)
  769:             {
  770:                 var list = dictionary.OrderBy(u => u.Value).ToDictionary<string, string>();
  771:  
  772:                 trek.DownloadedCountrySelectList = new SelectList(list, "Key", "Value");
  773:  
  774:                 //downloadedCountryDropDownList.DataTextField = "Value";
  775:                 //downloadedCountryDropDownList.DataValueField = "Key";
  776:  
  777:                 //downloadedCountryDropDownList.SelectedIndex = -1;
  778:                 //downloadedCountryDropDownList.DataBind();
  779:  
  780:                 //if (downloadedCountryDropDownList.Items.Count > 0) downloadedCountryDropDownList.SelectedIndex = (index < downloadedCountryDropDownList.Items.Count) ? index : 0;
  781:             }
  782:             //else downloadedCountryDropDownList.Items.Clear();
  783:         }
  784:  
  785:         /////////////////////////////////////////////////////////////////////////////////
  786:         /////////////////////////////////////////////////////////////////////////////////
  787:  
  788:         /// <summary>
  789:         ///
  790:         /// </summary>
  791:         public IActionResult Country(string iso3)
  792:         {
  793:             int featureCount, administrative, populated, vegetation, locality, undersea, street, hypsographic, hydrographic, spot;
  794:             Ia.Cl.Models.Result result;
  795:  
  796:             var feature = new Ia.TentPlay.Cl.Models.Trek.Feature();
  797:  
  798:             var featureList = new List<Ia.TentPlay.Cl.Models.Trek.Feature>();
  799:  
  800:             if (!string.IsNullOrEmpty(iso3))
  801:             {
  802:                 var applicationCountry = (from c in Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.CountryList
  803:                                           where c.Iso3 == iso3.ToUpper()
  804:                                           select c).SingleOrDefault();
  805:  
  806:                 if (applicationCountry != null)
  807:                 {
  808:                     var country = (from c in Ia.Cl.Models.Country.List
  809:                                    where c.Iso3 == applicationCountry.Iso3
  810:                                    select c).SingleOrDefault();
  811:  
  812:                     featureList = Ia.TentPlay.Cl.Models.Data.Trek.Feature.List(country, 1000, out result);
  813:  
  814:                     Ia.TentPlay.Cl.Models.Data.Trek.Feature.Statistic(country.Iso3, out featureCount, out administrative, out populated, out vegetation, out locality, out undersea, out street, out hypsographic, out hydrographic, out spot, out result);
  815:  
  816:                     applicationCountry.FeatureCount = featureCount;
  817:                     applicationCountry.AdministrativeFeatureCount = administrative;
  818:                     applicationCountry.PopulatedFeatureCount = populated;
  819:                     applicationCountry.VegetationFeatureCount = vegetation;
  820:                     applicationCountry.LocalityFeatureCount = locality;
  821:                     applicationCountry.UnderseaFeatureCount = undersea;
  822:                     applicationCountry.StreetFeatureCount = street;
  823:                     applicationCountry.HypsographicFeatureCount = hypsographic;
  824:                     applicationCountry.HydrographicFeatureCount = hydrographic;
  825:                     applicationCountry.SpotFeatureCount = spot;
  826:  
  827:                     trek.ApplicationCountry = applicationCountry;
  828:                     trek.FeatureList = featureList;
  829:                 }
  830:                 else
  831:                 {
  832:                 }
  833:             }
  834:             else
  835:             {
  836:             }
  837:  
  838:             /*
  839:             if (result.IsSuccessful)
  840:             {
  841:                 ViewBag.ResultMessage = result.Message;
  842:                 ViewBag.ResultClass = "success";
  843:             }
  844:             else
  845:             {
  846:                 ViewBag.ResultMessage = result.Message;
  847:                 ViewBag.ResultClass = "error";
  848:             }
  849:             */
  850:  
  851:             return View(trek);
  852:         }
  853:  
  854:         /////////////////////////////////////////////////////////////////////////////////
  855:  
  856:         /// <summary>
  857:         ///
  858:         /// </summary>
  859:         public IActionResult Feature(string id)
  860:         {
  861:             trek.Feature = new Ia.TentPlay.Cl.Models.Trek.Feature();
  862:  
  863:             if (!string.IsNullOrEmpty(id))
  864:             {
  865:                 trek.Feature = Ia.TentPlay.Cl.Models.Data.Trek.Feature.ById(id);
  866:             }
  867:             else
  868:             {
  869:             }
  870:  
  871:             /*
  872:             if (result.IsSuccessful)
  873:             {
  874:                 ViewBag.ResultMessage = result.Message;
  875:                 ViewBag.ResultClass = "success";
  876:             }
  877:             else
  878:             {
  879:                 ViewBag.ResultMessage = result.Message;
  880:                 ViewBag.ResultClass = "error";
  881:             }
  882:             */
  883:  
  884:             return View(trek);
  885:         }
  886:  
  887:         /////////////////////////////////////////////////////////////////////////////////
  888:  
  889:         /// <summary>
  890:         ///
  891:         /// </summary>
  892:         public IActionResult List() { return View(); }
  893:  
  894:         /////////////////////////////////////////////////////////////////////////////////
  895:  
  896:         /// <summary>
  897:         ///
  898:         /// </summary>
  899:         public IActionResult Search() { return View(); }
  900:  
  901:         /////////////////////////////////////////////////////////////////////////////////
  902:  
  903:         /// <summary>
  904:         ///
  905:         /// </summary>
  906:         [HttpPost]
  907:         public IActionResult Search(string textInput)
  908:         {
  909:             trek.FeatureList = ProcessSearch(textInput, out Ia.Cl.Models.Result result);
  910:  
  911:             if (result.IsSuccessful)
  912:             {
  913:                 ViewBag.ResultMessage = result.Message;
  914:                 ViewBag.ResultClass = "success";
  915:             }
  916:             else
  917:             {
  918:                 ViewBag.ResultMessage = result.Message;
  919:                 ViewBag.ResultClass = "error";
  920:             }
  921:  
  922:             return View(trek);
  923:         }
  924:  
  925:         /////////////////////////////////////////////////////////////////////////////////
  926:  
  927:         /// <summary>
  928:         ///
  929:         /// </summary>
  930:         protected List<Ia.TentPlay.Cl.Models.Trek.Feature> ProcessSearch(string textInput, out Ia.Cl.Models.Result result)
  931:         {
  932:             List<Ia.TentPlay.Cl.Models.Trek.Feature> list;
  933:  
  934:             result = new Ia.Cl.Models.Result();
  935:  
  936:             var text = WebUtility.HtmlEncode(textInput);
  937:  
  938:             if (!string.IsNullOrEmpty(text))
  939:             {
  940:                 list = Ia.TentPlay.Cl.Models.Data.Trek.Feature.Search(null, text, 100, out result);
  941:             }
  942:             else
  943:             {
  944:                 list = new List<Ia.TentPlay.Cl.Models.Trek.Feature>();
  945:  
  946:                 result.AddError("Please enter search term.");
  947:             }
  948:  
  949:             return list;
  950:         }
  951:  
  952:         /////////////////////////////////////////////////////////////////////////////////
  953:  
  954:         /// <summary>
  955:         ///
  956:         /// </summary>
  957:         [Route("/trek/legal/index")]
  958:         public IActionResult LegalIndex() { return View(); }
  959:  
  960:         /////////////////////////////////////////////////////////////////////////////////
  961:  
  962:         /// <summary>
  963:         ///
  964:         /// </summary>
  965:         [Route("/trek/legal/privacy")]
  966:         public IActionResult LegalPrivacy() { return View(); }
  967:  
  968:         /////////////////////////////////////////////////////////////////////////////////
  969:  
  970:         /// <summary>
  971:         ///
  972:         /// </summary>
  973:         [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
  974:         public IActionResult Error()
  975:         {
  976:             return View(new Ia.TentPlay.Wa.Models.ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
  977:         }
  978:  
  979:         /////////////////////////////////////////////////////////////////////////////////
  980:         /////////////////////////////////////////////////////////////////////////////////
  981:     }
  982:  
  983:     /////////////////////////////////////////////////////////////////////////////////
  984:     /////////////////////////////////////////////////////////////////////////////////
  985: }