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