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

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

Prayer Time 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:      /// Prayer Time 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:   
  30:      public class PrayerTimeController : ApiController
  31:      {
  32:          ////////////////////////////////////////////////////////////////////////////
  33:   
  34:          /// <summary>
  35:          /// 
  36:          /// </summary>
  37:          public PrayerTimeController()
  38:          {
  39:          }
  40:   
  41:          ////////////////////////////////////////////////////////////////////////////
  42:   
  43:          /// <summary>
  44:          ///
  45:          /// </summary>
  46:          [HttpGet]
  47:          public Ia.Islamic.Koran.Cl.Model.Business.PrayerTime PrayerTime(double latitude, double longitude)
  48:          {
  49:              int year, month, day, timeZone, hour, minute;
  50:              string[] sp;
  51:              DateTime now;
  52:              DateTime[] dateTimeList;
  53:              Ia.Islamic.Koran.Cl.Model.Business.PrayerTime prayerTime;
  54:              Ia.Cl.Model.PrayerTime prayerTimeLibraryClass;
  55:   
  56:              prayerTimeLibraryClass = new Ia.Cl.Model.PrayerTime();
  57:              dateTimeList = new DateTime[7];
  58:              prayerTime = new Ia.Islamic.Koran.Cl.Model.Business.PrayerTime();
  59:   
  60:              try
  61:              {
  62:                  now = DateTime.Now;
  63:   
  64:                  prayerTimeLibraryClass.SetCalcMethod(3);
  65:                  prayerTimeLibraryClass.SetAsrMethod(0);
  66:   
  67:                  year = now.Year;
  68:                  month = now.Month;
  69:                  day = now.Day;
  70:   
  71:                  timeZone = System.TimeZoneInfo.Local.GetUtcOffset(new DateTime(year, month, day)).Hours;
  72:   
  73:                  sp = prayerTimeLibraryClass.GetDatePrayerTimes(year, month, day, latitude, longitude, timeZone);
  74:   
  75:                  for (int i = 0; i < sp.Length; i++)
  76:                  {
  77:                      hour = int.Parse(sp[i].Split(':')[0]);
  78:                      minute = int.Parse(sp[i].Split(':')[1]);
  79:   
  80:                      dateTimeList[i] = new DateTime(now.Year, now.Month, now.Day, hour, minute, now.Second);
  81:                  }
  82:   
  83:                  prayerTime.Fajr = dateTimeList[0];
  84:                  prayerTime.Sunrize = dateTimeList[1];
  85:                  prayerTime.Dhuhr = dateTimeList[2];
  86:                  prayerTime.Asr = dateTimeList[3];
  87:                  prayerTime.Maghrib = dateTimeList[4];
  88:                  prayerTime.Isha = dateTimeList[6];
  89:              }
  90:              catch (Exception)
  91:              {
  92:                  prayerTime = null;
  93:              }
  94:   
  95:              return prayerTime;
  96:          }
  97:   
  98:          ////////////////////////////////////////////////////////////////////////////
  99:   
 100:          /// <summary>
 101:          ///
 102:          /// </summary>
 103:          [HttpGet]
 104:          public Ia.Islamic.Koran.Cl.Model.Business.PrayerTimeForCity PrayerTime(string ip)
 105:          {
 106:              Ia.Islamic.Koran.Cl.Model.Business.PrayerTimeForCity p;
 107:   
 108:              p = null;
 109:   
 110:              try
 111:              {
 112:                  //kw.com.ia.GeoIPClient client = new kw.com.ia.GeoIPClient();
 113:                  //kw.com.ia.CountryInfo countryInfo = client.GetCountryFromIP(iP/*"91.140.228.219"*/);
 114:   
 115:                  /*
 116:                  if (countryInfo != null)
 117:                  {
 118:                      //p.CityName = countryInfo
 119:                  }
 120:  
 121:                  client.Close();
 122:                   */
 123:              }
 124:              catch (Exception)
 125:              {
 126:              }
 127:   
 128:              return p;
 129:          }
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////
 132:          ////////////////////////////////////////////////////////////////////////////
 133:      }
 134:   
 135:      ////////////////////////////////////////////////////////////////////////////
 136:      ////////////////////////////////////////////////////////////////////////////
 137:  }