شركة التطبيقات المتكاملة لتصميم النظم البرمجية الخاصة

Integrated Applications Programming Company

Skip Navigation LinksHome » Code Library » DefaultController

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

Default API Controller class.

   1:  using System;
   2:  using System.Web.Http;
   3:   
   4:  namespace Ia.Ngn.Cl.Model.Api.Controller
   5:  {
   6:      ////////////////////////////////////////////////////////////////////////////
   7:   
   8:      /// <summary publish="true">
   9:      /// Default API Controller class.
  10:      /// </summary>
  11:      /// 
  12:      /// <remarks> 
  13:      /// Copyright © 2001-2018 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:      public class DefaultController : ApiController
  26:      {
  27:          ////////////////////////////////////////////////////////////////////////////
  28:   
  29:          /// <summary>
  30:          ///
  31:          /// </summary>
  32:          public DefaultController()
  33:          {
  34:          }
  35:   
  36:          ////////////////////////////////////////////////////////////////////////////
  37:   
  38:          /// <summary>
  39:          /// Check the validity of a password and return true if password is accepted for host.
  40:          /// </summary>
  41:          [HttpGet]
  42:          public bool Validate(string password, string uriString)
  43:          {
  44:              bool isValid;
  45:              Uri uri;
  46:   
  47:              if (!string.IsNullOrEmpty(uriString))
  48:              {
  49:                  try
  50:                  {
  51:                      uri = new System.Uri("http://" + uriString);
  52:   
  53:                      isValid = Ia.Cl.Model.Authentication.Validate(password, uri);
  54:                  }
  55:                  catch (UriFormatException)
  56:                  {
  57:                      isValid = false;
  58:                  }
  59:              }
  60:              else isValid = false;
  61:   
  62:              return isValid;
  63:          }
  64:   
  65:          ////////////////////////////////////////////////////////////////////////////
  66:   
  67:          /// <summary>
  68:          /// Echo the passed string
  69:          /// </summary>
  70:          [HttpGet]
  71:          public string Echo(string text)
  72:          {
  73:              return text;
  74:          }
  75:   
  76:          ////////////////////////////////////////////////////////////////////////////
  77:   
  78:          /// <summary>
  79:          /// Return current time
  80:          /// </summary>
  81:          [HttpGet]
  82:          public string Time()
  83:          {
  84:              return DateTime.UtcNow.AddHours(3).ToString("yyyy-MM-dd HH:mm:ss.fff");
  85:          }
  86:   
  87:          ////////////////////////////////////////////////////////////////////////////
  88:          ////////////////////////////////////////////////////////////////////////////
  89:      }
  90:   
  91:      ////////////////////////////////////////////////////////////////////////////
  92:      ////////////////////////////////////////////////////////////////////////////
  93:  }