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

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

Trek API Controller class of Tent Play's model.

    1: using Microsoft.AspNetCore.Mvc;
    2: using System.Runtime.Serialization;
    3:  
    4: namespace Ia.TentPlay.Api.Wa.Controllers
    5: {
    6:     ////////////////////////////////////////////////////////////////////////////
    7:  
    8:     /// <summary publish="true">
    9:     /// Trek API Controller class of Tent Play's model.
   10:     /// </summary>
   11:     /// 
   12:     /// <remarks> 
   13:     /// Copyright © 2019-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   14:     ///
   15:     /// 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
   16:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   17:     ///
   18:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   19:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   20:     /// 
   21:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   22:     /// 
   23:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   24:     /// </remarks> 
   25:     [ApiController]
   26:     [Route("api")]
   27:     public class DefaultController : ControllerBase
   28:     {
   29:         private readonly ILogger<DefaultController> _logger;
   30:  
   31:         ////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         ///
   35:         /// </summary>
   36:         public DefaultController(ILogger<DefaultController> logger)
   37:         {
   38:             _logger = logger;
   39:         }
   40:  
   41:         ////////////////////////////////////////////////////////////////////////////
   42:  
   43:         /// <summary>
   44:         /// 
   45:         /// </summary>
   46:         [DataContract(IsReference = true, Namespace = "com.tentplay.api", Name = "TrekCountry")]
   47:         public class TrekCountryResult
   48:         {
   49:             ////////////////////////////////////////////////////////////////////////////
   50:  
   51:             /// <summary>
   52:             /// 
   53:             /// </summary>
   54:             [DataMember(Name = "iso3")]
   55:             public string Iso3 { get; set; }
   56:  
   57:             ////////////////////////////////////////////////////////////////////////////
   58:  
   59:             /// <summary>
   60:             /// 
   61:             /// </summary>
   62:             [DataMember(Name = "applicationNameDictionaryEnglish")]
   63:             public string ApplicationNameDictionaryEnglish { get; set; }
   64:  
   65:             ////////////////////////////////////////////////////////////////////////////
   66:  
   67:             /// <summary>
   68:             /// 
   69:             /// </summary>
   70:             [DataMember(Name = "applicationUrl")]
   71:             public string ApplicationUrl { get; set; }
   72:  
   73:             ////////////////////////////////////////////////////////////////////////////
   74:  
   75:             /// <summary>
   76:             /// 
   77:             /// </summary>
   78:             [DataMember(Name = "hiResIconImageUrl")]
   79:             public string HiResIconImageUrl { get; set; }
   80:         }
   81:  
   82:         ////////////////////////////////////////////////////////////////////////////
   83:  
   84:         /// <summary>
   85:         ///
   86:         /// </summary>
   87:         [HttpGet]
   88:         [Route("trek/countries/{iso3}")]
   89:         public TrekCountryResult GetCountry(string iso3)
   90:         {
   91:             //string shortDescription, about;
   92:             TrekCountryResult trekCountryGetResult;
   93:             Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country country;
   94:  
   95:             iso3 = iso3.ToUpper();
   96:  
   97:             country = (from c in Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.CountryList
   98:                        where c.Iso3 == iso3
   99:                        select c).SingleOrDefault();
  100:  
  101:             // below: database based too slow and not fully suitable
  102:             //shortDescription = country.Translations.First().ShortDescription;
  103:             //about = country.Translations.First().About;
  104:  
  105:             if (country != null)
  106:             {
  107:                 trekCountryGetResult = new TrekCountryResult()
  108:                 {
  109:                     Iso3 = country.Iso3,
  110:                     ApplicationNameDictionaryEnglish = country.ApplicationNameDictionary["en"],
  111:                     ApplicationUrl = country.ApplicationUrl,
  112:                     HiResIconImageUrl = country.HiResIconImageUrl,
  113:                     //ShortDescription = shortDescription,
  114:                     //About = about,
  115:                 };
  116:             }
  117:             else
  118:             {
  119:                 trekCountryGetResult = new TrekCountryResult();
  120:             }
  121:  
  122:             return trekCountryGetResult;
  123:         }
  124:  
  125:         ////////////////////////////////////////////////////////////////////////////
  126:  
  127:         /// <summary>
  128:         ///
  129:         /// </summary>
  130:         [HttpGet]
  131:         [Route("trek/countries")]
  132:         public List<TrekCountryResult> GetCountries()
  133:         {
  134:             List<TrekCountryResult> trekCountryGetResultList;
  135:             List<Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country> list;
  136:  
  137:             list = Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.CountryList;
  138:  
  139:             if (list.Count > 0)
  140:             {
  141:                 trekCountryGetResultList = new List<TrekCountryResult>();
  142:  
  143:                 foreach (Ia.TentPlay.Cl.Models.Data.Trek.ApplicationInformation.Country country in list)
  144:                 {
  145:                     if (country.Published > DateTime.MinValue)
  146:                     {
  147:                         trekCountryGetResultList.Add(new TrekCountryResult()
  148:                         {
  149:                             Iso3 = country.Iso3,
  150:                             ApplicationNameDictionaryEnglish = country.ApplicationNameDictionary["en"],
  151:                             ApplicationUrl = country.ApplicationUrl,
  152:                             HiResIconImageUrl = country.HiResIconImageUrl,
  153:                             //ShortDescription = shortDescription,
  154:                             //About = about,
  155:                         });
  156:                     }
  157:                 }
  158:             }
  159:             else
  160:             {
  161:                 trekCountryGetResultList = new List<TrekCountryResult>();
  162:             }
  163:  
  164:             return trekCountryGetResultList;
  165:         }
  166:  
  167:         ////////////////////////////////////////////////////////////////////////////
  168:         ////////////////////////////////////////////////////////////////////////////
  169:     }
  170:  
  171:     ////////////////////////////////////////////////////////////////////////////
  172:     ////////////////////////////////////////////////////////////////////////////
  173: }