)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » KoranController (Ia.Islamic.Koran.Cl.Model.Api.Controller)

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.Runtime.Serialization;
    6: using Microsoft.AspNetCore.Mvc;
    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-2020 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 class KoranController : ControllerBase
   30:     {
   31:         ////////////////////////////////////////////////////////////////////////////
   32:  
   33:         /// <summary>
   34:         /// 
   35:         /// </summary>
   36:         public KoranController()
   37:         {
   38:         }
   39:  
   40:         ////////////////////////////////////////////////////////////////////////////
   41:  
   42:         /// <summary>
   43:         ///
   44:         /// </summary>
   45:         [HttpGet]
   46:         [Route("api/islamic/koran/search/{languageSymbol}/{searchTerm}")]
   47:         public List<Ia.Islamic.Cl.Model.Ui.VerseUi> Search(string languageSymbol, string searchTerm)
   48:         {
   49:             var verseList = Ia.Islamic.Cl.Model.Business.Default.Search(searchTerm, languageSymbol, out Ia.Cl.Models.Result result);
   50:  
   51:             return verseList;
   52:         }
   53:  
   54:         ////////////////////////////////////////////////////////////////////////////
   55:  
   56:         /// <summary>
   57:         ///
   58:         /// </summary>
   59:         [HttpGet]
   60:         [Route("api/islamic/koran/verse/{languageSymbol}/{chapterNumber}/{verseNumber}")]
   61:         public Ia.Islamic.Cl.Model.Ui.VerseUi Verse(string languageSymbol, int chapterNumber, int verseNumber)
   62:         {
   63:             var language = new Ia.Cl.Models.Language(languageSymbol);
   64:  
   65:             return Ia.Islamic.Cl.Model.Business.Default.Verse(language, chapterNumber, verseNumber, out int op, out string result);
   66:         }
   67:  
   68:         ////////////////////////////////////////////////////////////////////////////
   69:  
   70:         /// <summary>
   71:         ///  Return a calculated faith verse(s) according to language and topic.
   72:         /// </summary>
   73:         [HttpGet]
   74:         [Route("api/islamic/koran/faith/calculated-verse/{languageSymbol}/{topic}")]
   75:         public Ia.Islamic.Cl.Model.Ui.VerseTopicUi CalculatedFaithVerse(string languageSymbol, string topic)
   76:         {
   77:             int  chapterNumber, verseNumber, numberOfVerses;
   78:  
   79:             //#if DEBUG
   80:             if (languageSymbol == null) languageSymbol = "en";
   81:             //#endif
   82:  
   83:             var random = new Random();
   84:             var language = new Ia.Cl.Models.Language(languageSymbol);
   85:  
   86:             // below: read all verse topic
   87:             var verseTopicList = Ia.Islamic.Cl.Model.Data.VerseTopic.List();
   88:  
   89:             if (verseTopicList.Count() > 0)
   90:             {
   91:                 // below: randomly select a signle entry
   92:                 var r = random.Next(verseTopicList.Count);
   93:  
   94:                 chapterNumber = verseTopicList[r].ChapterNumber;
   95:                 verseNumber = verseTopicList[r].VerseNumber;
   96:                 numberOfVerses = verseTopicList[r].NumberOfVerses;
   97:             }
   98:             else
   99:             {
  100:                 chapterNumber = 46;
  101:                 verseNumber = 1;
  102:                 numberOfVerses = 7;
  103:             }
  104:  
  105:             return Ia.Islamic.Cl.Model.Business.Default.VerseSpan(language, chapterNumber, verseNumber, numberOfVerses, out int op, out string result);
  106:         }
  107:  
  108:         ////////////////////////////////////////////////////////////////////////////
  109:         ////////////////////////////////////////////////////////////////////////////
  110:     }
  111: }