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