Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » KoranController

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

Koran API Controller class of Islamic Koran Reference Network project model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Net;
   5:  using System.Web.Http;
   6:  using System.Runtime.Serialization;
   7:   
   8:  namespace Ia.Islamic.Koran.Cl.Model.Api.Controller
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Koran API Controller class of Islamic Koran Reference Network project model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2006-2016 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet 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 class KoranController : ApiController
  30:      {
  31:          ////////////////////////////////////////////////////////////////////////////
  32:   
  33:          /// <summary>
  34:          /// 
  35:          /// </summary>
  36:          public KoranController()
  37:          {
  38:          }
  39:   
  40:          ////////////////////////////////////////////////////////////////////////////
  41:   
  42:          /// <summary>
  43:          ///
  44:          /// </summary>
  45:          [HttpGet]
  46:          public List<Ia.Islamic.Cl.Model.Ui.VerseUi> Search(string languageSymbol, string searchTerm)
  47:          {
  48:              int op;
  49:              string result;
  50:              List<Ia.Islamic.Cl.Model.Ui.VerseUi> verseList;
  51:   
  52:              verseList = Ia.Islamic.Cl.Model.Business.Default.Search(searchTerm, languageSymbol, out op, out result);
  53:   
  54:              return verseList;
  55:          }
  56:   
  57:          ////////////////////////////////////////////////////////////////////////////
  58:   
  59:          /// <summary>
  60:          ///
  61:          /// </summary>
  62:          [HttpGet]
  63:          public Ia.Islamic.Cl.Model.Ui.VerseUi Verse(string languageSymbol, int chapterNumber, int verseNumber)
  64:          {
  65:              int op;
  66:              string result;
  67:              Ia.Cl.Model.Language language;
  68:   
  69:              language = new Ia.Cl.Model.Language(languageSymbol);
  70:   
  71:              return Ia.Islamic.Cl.Model.Business.Default.Verse(language, chapterNumber, verseNumber, out op, out result);
  72:          }
  73:   
  74:          ////////////////////////////////////////////////////////////////////////////
  75:   
  76:          /// <summary>
  77:          ///  Return a calculated faith verse(s) according to language and topic.
  78:          /// </summary>
  79:          [HttpGet]
  80:          public Ia.Islamic.Cl.Model.Ui.VerseTopicUi CalculatedFaithVerse(string languageSymbol, string topic)
  81:          {
  82:              Random random;
  83:              int op, r, chapterNumber, verseNumber, numberOfVerses;
  84:              string result;
  85:              Ia.Cl.Model.Language language;
  86:              List<Ia.Islamic.Cl.Model.VerseTopic> verseTopicList;
  87:   
  88:              //#if DEBUG
  89:              if (languageSymbol == null) languageSymbol = "en";
  90:              //#endif
  91:   
  92:              random = new Random();
  93:              language = new Ia.Cl.Model.Language(languageSymbol);
  94:   
  95:              // below: read all verse topic
  96:              verseTopicList = Ia.Islamic.Cl.Model.Data.VerseTopic.List();
  97:   
  98:              if (verseTopicList.Count() > 0)
  99:              {
 100:                  // below: randomly select a signle entry
 101:                  r = random.Next(verseTopicList.Count);
 102:   
 103:                  chapterNumber = verseTopicList[r].ChapterNumber;
 104:                  verseNumber = verseTopicList[r].VerseNumber;
 105:                  numberOfVerses = verseTopicList[r].NumberOfVerses;
 106:              }
 107:              else
 108:              {
 109:                  chapterNumber = 46;
 110:                  verseNumber = 1;
 111:                  numberOfVerses = 7;
 112:              }
 113:   
 114:              return Ia.Islamic.Cl.Model.Business.Default.VerseSpan(language, chapterNumber, verseNumber, numberOfVerses, out op, out result);
 115:          }
 116:   
 117:          ////////////////////////////////////////////////////////////////////////////
 118:          ////////////////////////////////////////////////////////////////////////////
 119:      }
 120:  }