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

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

Koran Reference Network Class Library support functions: UI model

    1: using System;
    2: using System.Collections.Generic;
    3: using System.Linq;
    4: using System.Text;
    5: using System.Threading.Tasks;
    6: using Microsoft.EntityFrameworkCore;
    7:  
    8: namespace Ia.Islamic.Cl.Model.Ui
    9: {
   10:     ////////////////////////////////////////////////////////////////////////////
   11:  
   12:     /// <summary publish="true">
   13:     /// Koran Reference Network Class Library support functions: UI model
   14:     /// </summary>
   15:     /// <value>
   16:     /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
   17:     /// </value>
   18:     /// <remarks> 
   19:     /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   20:     ///
   21:     /// 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
   22:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   23:     ///
   24:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   25:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   26:     /// 
   27:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   28:     /// 
   29:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   30:     /// </remarks> 
   31:     public class VerseTopicUi
   32:     {
   33:         public string Id { get; set; }
   34:         public int Number { get; set; }
   35:         public int ChapterNumber { get; set; }
   36:         public int? TopicId { get; set; }
   37:         public int? NumberOfVerses { get; set; }
   38:  
   39:         public string Content { get; set; }
   40:  
   41:         public string ChapterVerseNumber
   42:         {
   43:             get
   44:             {
   45:                 return ChapterNumber + ":" + Number;
   46:             }
   47:         }
   48:  
   49:         ////////////////////////////////////////////////////////////////////////////
   50:  
   51:         /// <summary>
   52:         /// 
   53:         /// </summary>
   54:         public static List<VerseTopicUi> ReturnVerseTopicListUsingLanguageSymbolAndChapter(string languageSymbol, int chapterNumber, out int op, out string result)
   55:         {
   56:             List<VerseTopicUi> verseTopicList;
   57:  
   58:             op = 0;
   59:             result = "";
   60:             verseTopicList = null;
   61:  
   62:             try
   63:             {
   64:                 using (var db = new Ia.Islamic.Cl.Model.Context.Koran())
   65:                 {
   66:                     var query = from q in db.VerseTopics
   67:                                 //join q2 in db.Verses on q.VerseNumber equals q2.Number
   68:                                 where /*q2.Chapter.Koran.Language.Symbol == languageSymbol &&*/ q.ChapterNumber == chapterNumber
   69:                                 select new VerseTopicUi
   70:                                 {
   71:                                     Id = q.Id,
   72:                                     Number = q.VerseNumber,
   73:                                     ChapterNumber = q.ChapterNumber,
   74:                                     NumberOfVerses = q.NumberOfVerses,
   75:                                     TopicId = q.TopicId,
   76:                                     Content = "" //q2.Content
   77:                                 };
   78:  
   79:                     verseTopicList = (query).OrderBy(p => p.Id).ToList();
   80:  
   81:                     // below: a single content
   82:                     VerseTopicUi tempVerseTopicUI;
   83:  
   84:                     foreach (VerseTopicUi vt in verseTopicList)
   85:                     {
   86:                         tempVerseTopicUI = VerseTopic(new Ia.Cl.Models.Language("ar"), chapterNumber, vt.Number, vt.NumberOfVerses, out op, out result);
   87:  
   88:                         if (tempVerseTopicUI.Content != null) vt.Content = tempVerseTopicUI.Content;
   89:                     }
   90:  
   91:                     if (verseTopicList.Count() > 0) op = 1;
   92:                 }
   93:             }
   94:             catch (Exception ex)
   95:             {
   96:                 op = -1;
   97:                 result = "Exception: " + ex.Message + ". ";
   98:                 verseTopicList = null;
   99:             }
  100:  
  101:             return verseTopicList;
  102:         }
  103:  
  104:         ////////////////////////////////////////////////////////////////////////////
  105:  
  106:         /// <summary>
  107:         /// 
  108:         /// </summary>
  109:         public static VerseTopicUi VerseTopic(Ia.Cl.Models.Language language, int chapterNumber, int verseNumber, int? numberOfVerses, out int op, out string result)
  110:         {
  111:             VerseTopicUi verse;
  112:             List<VerseTopicUi> verseList;
  113:  
  114:             op = 0;
  115:             result = "";
  116:             verse = new VerseTopicUi();
  117:  
  118:             try
  119:             {
  120:                 using (var db = new Ia.Islamic.Cl.Model.Context.Koran())
  121:                 {
  122:                     verseList = (from q in db.Verses
  123:                                  where q.Chapter.Koran.LanguageIso == language.Id
  124:                                  && q.Chapter.Number == chapterNumber
  125:                                  && q.Number >= verseNumber
  126:                                  && q.Number <= verseNumber + (numberOfVerses - 1)
  127:                                  select new VerseTopicUi
  128:                                  {
  129:                                      Id = q.Id,
  130:                                      Number = q.Number,
  131:                                      ChapterNumber = q.Chapter.Number,
  132:                                      Content = q.Content
  133:                                  }).OrderBy(p => p.Id).ToList();
  134:  
  135:                     if (verseList.Count() > 0)
  136:                     {
  137:                         verse.Number = verseList[0].Number;
  138:                         verse.ChapterNumber = verseList[0].ChapterNumber;
  139:                         verse.NumberOfVerses = numberOfVerses;
  140:  
  141:                         foreach (VerseTopicUi v in verseList)
  142:                         {
  143:                             verse.Content += v.Content + " ";
  144:                         }
  145:  
  146:                         op = 1;
  147:                     }
  148:                     else
  149:                     {
  150:                         //op = -1;
  151:                         //result = "Error: ReturnTopicVerseUsingLanguageAndChapterNumberAndVerseNumberAndNumberOfVerses()";
  152:                     }
  153:                 }
  154:             }
  155:             catch (Exception ex)
  156:             {
  157:                 op = -1;
  158:                 result = "Exception: " + ex.Message + ". ";
  159:                 verse = null;
  160:             }
  161:  
  162:             return verse;
  163:         }
  164:  
  165:         ////////////////////////////////////////////////////////////////////////////
  166:         ////////////////////////////////////////////////////////////////////////////
  167:     }
  168:  
  169:     ////////////////////////////////////////////////////////////////////////////
  170:     ////////////////////////////////////////////////////////////////////////////
  171: }