)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » ServiceRequest (Ia.Ftn.Wa.Models.Provision)

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

    1: using Microsoft.AspNetCore.Mvc.Rendering;
    2: using System.Data;
    3:  
    4: namespace Ia.Ftn.Wa.Models.Provision
    5: {
    6:     ////////////////////////////////////////////////////////////////////////////
    7:  
    8:     /// <summary publish="true">
    9:     ///
   10:     /// </summary>
   11:     /// 
   12:     /// <remarks> 
   13:     /// Copyright © 2006-2025 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   14:     ///
   15:     /// 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
   16:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   17:     ///
   18:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   19:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   20:     /// 
   21:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   22:     /// 
   23:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   24:     /// </remarks> 
   25:     public static class ServiceRequest
   26:     {
   27:         private static int startYear = 1960;
   28:         private static DateTime selectedDate;
   29:  
   30:         ////////////////////////////////////////////////////////////////////////////
   31:  
   32:         /// <summary>
   33:         ///
   34:         /// </summary>
   35:         public static void ViewModel(ref Ia.Ftn.Wa.Models.Provision.ServiceRequestViewModel serviceRequestViewModel)
   36:         {
   37:             var nowDateTime = DateTime.UtcNow.AddHours(3);
   38:  
   39:             var yearList = new List<int>();
   40:             var monthList = new List<int>();
   41:             var dayList = new List<int>();
   42:  
   43:             for (int year = startYear; year <= nowDateTime.Year; year++) yearList.Add(year);
   44:  
   45:             for (int month = 1; month <= 12; month++) monthList.Add(month);
   46:  
   47:             for (int day = 1; day <= DateTime.DaysInMonth(selectedDate.Year, selectedDate.Month); day++) dayList.Add(day);
   48:  
   49:             serviceRequestViewModel.YearSelectList = new SelectList(yearList);
   50:             serviceRequestViewModel.YearSelectedValue = serviceRequestViewModel.YearSelectedValue == 0 ? nowDateTime.Year : serviceRequestViewModel.YearSelectedValue;
   51:  
   52:             serviceRequestViewModel.MonthSelectList = new SelectList(monthList);
   53:             serviceRequestViewModel.MonthSelectedValue = serviceRequestViewModel.MonthSelectedValue == 0 ? nowDateTime.Month : serviceRequestViewModel.MonthSelectedValue;
   54:  
   55:             serviceRequestViewModel.DaySelectList = new SelectList(dayList);
   56:             serviceRequestViewModel.DaySelectedValue = serviceRequestViewModel.DaySelectedValue == 0 ? nowDateTime.Day : serviceRequestViewModel.DaySelectedValue;
   57:         }
   58:  
   59:         ////////////////////////////////////////////////////////////////////////////
   60:  
   61:         /// <summary>
   62:         ///
   63:         /// </summary>
   64:         public static void Post(ref Ia.Ftn.Wa.Models.Provision.ServiceRequestViewModel serviceRequestViewModel, string commandName)
   65:         {
   66:             var daysInMonth = DateTime.DaysInMonth(serviceRequestViewModel.YearSelectedValue, serviceRequestViewModel.MonthSelectedValue);
   67:  
   68:             // handle changing from leap year with feb 29 to a non-leap year
   69:             if (serviceRequestViewModel.DaySelectedValue > daysInMonth) serviceRequestViewModel.DaySelectedValue = daysInMonth;
   70:  
   71:             selectedDate = new DateTime(serviceRequestViewModel.YearSelectedValue, serviceRequestViewModel.MonthSelectedValue, serviceRequestViewModel.DaySelectedValue);
   72:  
   73:             /*if (commandName == "filterForSelectedDate")*/
   74:             FilterForSelectedDate(ref serviceRequestViewModel, selectedDate);
   75:         }
   76:  
   77:         ////////////////////////////////////////////////////////////////////////////
   78:  
   79:         /// <summary>
   80:         ///
   81:         /// </summary>
   82:         private static void FilterForSelectedDate(ref Ia.Ftn.Wa.Models.Provision.ServiceRequestViewModel serviceRequestViewModel, DateTime selectedDate)
   83:         {
   84:             serviceRequestViewModel.TimeLabel = selectedDate.ToString("yyyy-MM-dd") + " (" + selectedDate.DayOfWeek.ToString() + ")";
   85:  
   86:             var serviceRequestList = Ia.Ftn.Cl.Models.Data.ServiceRequest.ForRequestDate(selectedDate).OrderBy(u => u.Id).ToList();
   87:             serviceRequestViewModel.ServiceRequestList = serviceRequestList;
   88:  
   89:             var serviceRequestHistoryList = Ia.Ftn.Cl.Models.Data.ServiceRequestHistory.ForRequestDate(selectedDate).OrderBy(u => u.Id).ToList();
   90:             serviceRequestViewModel.ServiceRequestHistoryList = serviceRequestHistoryList;
   91:         }
   92:  
   93:         ////////////////////////////////////////////////////////////////////////////
   94:         ////////////////////////////////////////////////////////////////////////////
   95:     }
   96:  
   97:     ////////////////////////////////////////////////////////////////////////////
   98:     ////////////////////////////////////////////////////////////////////////////
   99: }