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

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.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:     /// Prayer Time 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:  
   30:     public class PrayerTimeController : ControllerBase
   31:     {
   32:         ////////////////////////////////////////////////////////////////////////////
   33:  
   34:         /// <summary>
   35:         /// 
   36:         /// </summary>
   37:         public PrayerTimeController()
   38:         {
   39:         }
   40:  
   41:         ////////////////////////////////////////////////////////////////////////////
   42:  
   43:         /// <summary>
   44:         ///
   45:         /// </summary>
   46:         [HttpGet]
   47:         [Route("api/islamic/prayer-time/geographic-coordinate/{latitude}/{longitude}")]
   48:         public Ia.Islamic.Koran.Cl.Model.Business.PrayerTime PrayerTime(double latitude, double longitude)
   49:         {
   50:             int year, month, day, timeZone, hour, minute;
   51:             string[] sp;
   52:             DateTime now;
   53:             DateTime[] dateTimeList;
   54:             Ia.Islamic.Koran.Cl.Model.Business.PrayerTime prayerTime;
   55:             Ia.Cl.Models.PrayerTime prayerTimeLibraryClass;
   56:  
   57:             prayerTimeLibraryClass = new Ia.Cl.Models.PrayerTime();
   58:             dateTimeList = new DateTime[7];
   59:             prayerTime = new Ia.Islamic.Koran.Cl.Model.Business.PrayerTime();
   60:  
   61:             try
   62:             {
   63:                 now = DateTime.Now;
   64:  
   65:                 prayerTimeLibraryClass.SetCalcMethod(3);
   66:                 prayerTimeLibraryClass.SetAsrMethod(0);
   67:  
   68:                 year = now.Year;
   69:                 month = now.Month;
   70:                 day = now.Day;
   71:  
   72:                 timeZone = System.TimeZoneInfo.Local.GetUtcOffset(new DateTime(year, month, day)).Hours;
   73:  
   74:                 sp = prayerTimeLibraryClass.GetDatePrayerTimes(year, month, day, latitude, longitude, timeZone);
   75:  
   76:                 for (int i = 0; i < sp.Length; i++)
   77:                 {
   78:                     hour = int.Parse(sp[i].Split(':')[0]);
   79:                     minute = int.Parse(sp[i].Split(':')[1]);
   80:  
   81:                     dateTimeList[i] = new DateTime(now.Year, now.Month, now.Day, hour, minute, now.Second);
   82:                 }
   83:  
   84:                 prayerTime.Fajr = dateTimeList[0];
   85:                 prayerTime.Sunrize = dateTimeList[1];
   86:                 prayerTime.Dhuhr = dateTimeList[2];
   87:                 prayerTime.Asr = dateTimeList[3];
   88:                 prayerTime.Maghrib = dateTimeList[4];
   89:                 prayerTime.Isha = dateTimeList[6];
   90:             }
   91:             catch (Exception)
   92:             {
   93:                 prayerTime = null;
   94:             }
   95:  
   96:             return prayerTime;
   97:         }
   98:  
   99:         ////////////////////////////////////////////////////////////////////////////
  100:         ////////////////////////////////////////////////////////////////////////////
  101:     }
  102:  
  103:     ////////////////////////////////////////////////////////////////////////////
  104:     ////////////////////////////////////////////////////////////////////////////
  105: }