)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
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:         /// <summary/>
   34:         public string Id { get; set; }
   35:  
   36:         /// <summary/>
   37:         public int Number { get; set; }
   38:  
   39:         /// <summary/>
   40:         public int ChapterNumber { get; set; }
   41:  
   42:         /// <summary/>
   43:         public int? TopicId { get; set; }
   44:  
   45:         /// <summary/>
   46:         public int? NumberOfVerses { get; set; }
   47:  
   48:         /// <summary/>
   49:         public string Content { get; set; }
   50:  
   51:         /// <summary/>
   52:         public string ChapterVerseNumber
   53:         {
   54:             get
   55:             {
   56:                 return ChapterNumber + ":" + Number;
   57:             }
   58:         }
   59:  
   60:         ////////////////////////////////////////////////////////////////////////////
   61:  
   62:         /// <summary>
   63:         /// 
   64:         /// </summary>
   65:         public static List<VerseTopicUi> ReturnVerseTopicListUsingLanguageSymbolAndChapter(string languageSymbol, int chapterNumber, out int op, out string result)
   66:         {
   67:             List<VerseTopicUi> verseTopicList;
   68:  
   69:             op = 0;
   70:             result = "";
   71:             verseTopicList = null;
   72:  
   73:             try
   74:             {
   75:                 using (var db = new Ia.Islamic.Cl.KoranDbContext())
   76:                 {
   77:                     var query = from q in db.VerseTopics
   78:                                     //join q2 in db.Verses on q.VerseNumber equals q2.Number
   79:                                 where /*q2.Chapter.Koran.Language.Symbol == languageSymbol &&*/ q.ChapterNumber == chapterNumber
   80:                                 select new VerseTopicUi
   81:                                 {
   82:                                     Id = q.Id,
   83:                                     Number = q.VerseNumber,
   84:                                     ChapterNumber = q.ChapterNumber,
   85:                                     NumberOfVerses = q.NumberOfVerses,
   86:                                     TopicId = q.TopicId,
   87:                                     Content = "" //q2.Content
   88:                                 };
   89:  
   90:                     verseTopicList = (query).OrderBy(p => p.Id).ToList();
   91:  
   92:                     // below: a single content
   93:                     VerseTopicUi tempVerseTopicUI;
   94:  
   95:                     foreach (VerseTopicUi vt in verseTopicList)
   96:                     {
   97:                         tempVerseTopicUI = VerseTopic(new Ia.Cl.Models.Language("ar"), chapterNumber, vt.Number, vt.NumberOfVerses, out op, out result);
   98:  
   99:                         if (tempVerseTopicUI.Content != null) vt.Content = tempVerseTopicUI.Content;
  100:                     }
  101:  
  102:                     if (verseTopicList.Count() > 0) op = 1;
  103:                 }
  104:             }
  105:             catch (Exception ex)
  106:             {
  107:                 op = -1;
  108:                 result = "Exception: " + ex.Message + ". ";
  109:                 verseTopicList = null;
  110:             }
  111:  
  112:             return verseTopicList;
  113:         }
  114:  
  115:         ////////////////////////////////////////////////////////////////////////////
  116:  
  117:         /// <summary>
  118:         /// 
  119:         /// </summary>
  120:         public static VerseTopicUi VerseTopic(Ia.Cl.Models.Language language, int chapterNumber, int verseNumber, int? numberOfVerses, out int op, out string result)
  121:         {
  122:             VerseTopicUi verse;
  123:             List<VerseTopicUi> verseList;
  124:  
  125:             op = 0;
  126:             result = "";
  127:             verse = new VerseTopicUi();
  128:  
  129:             try
  130:             {
  131:                 using (var db = new Ia.Islamic.Cl.KoranDbContext())
  132:                 {
  133:                     verseList = (from q in db.Verses
  134:                                  where q.Chapter.Koran.LanguageIso == language.Id
  135:                                  && q.Chapter.Number == chapterNumber
  136:                                  && q.Number >= verseNumber
  137:                                  && q.Number <= verseNumber + (numberOfVerses - 1)
  138:                                  select new VerseTopicUi
  139:                                  {
  140:                                      Id = q.Id,
  141:                                      Number = q.Number,
  142:                                      ChapterNumber = q.Chapter.Number,
  143:                                      Content = q.Content
  144:                                  }).OrderBy(p => p.Id).ToList();
  145:  
  146:                     if (verseList.Count() > 0)
  147:                     {
  148:                         verse.Number = verseList[0].Number;
  149:                         verse.ChapterNumber = verseList[0].ChapterNumber;
  150:                         verse.NumberOfVerses = numberOfVerses;
  151:  
  152:                         foreach (VerseTopicUi v in verseList)
  153:                         {
  154:                             verse.Content += v.Content + " ";
  155:                         }
  156:  
  157:                         op = 1;
  158:                     }
  159:                     else
  160:                     {
  161:                         //op = -1;
  162:                         //result = "Error: ReturnTopicVerseUsingLanguageAndChapterNumberAndVerseNumberAndNumberOfVerses()";
  163:                     }
  164:                 }
  165:             }
  166:             catch (Exception ex)
  167:             {
  168:                 op = -1;
  169:                 result = "Exception: " + ex.Message + ". ";
  170:                 verse = null;
  171:             }
  172:  
  173:             return verse;
  174:         }
  175:  
  176:         ////////////////////////////////////////////////////////////////////////////
  177:         ////////////////////////////////////////////////////////////////////////////
  178:     }
  179:  
  180:     ////////////////////////////////////////////////////////////////////////////
  181:     ////////////////////////////////////////////////////////////////////////////
  182: }