コード例 #1
0
 public static bool openOrClosed(OperatingHours opHours, Indawo indawo)
 {
     if (opHours.openingHour <= DateTime.Now &&
         opHours.closingHour >= DateTime.Now && CheckDayBefore(opHours, indawo))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        private static bool CheckDayBefore(OperatingHours opHours, Indawo indawo)
        {
            var            daybefore       = getDayBefore(opHours);
            OperatingHours dayBeforeOphour = getDayBeforeOpHour(daybefore, indawo);

            if (dayBeforeOphour != null)
            {
                var dayBeforeClosingHour = dayBeforeOphour.closingHour.ToString();
                if (dayBeforeClosingHour.Split(' ')[1].Substring(0, 5).StartsWith("0"))
                {
                    if (dayBeforeOphour.closingHour.Hour > DateTime.Now.Hour)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #3
0
        private static string  getDayBefore(OperatingHours opHours)
        {
            var dayOfWeek = "monday,tuesday,wednesday,thursday,friday,saturday,sunday".Split(',');
            var prevDay   = "";

            for (int i = 0; i < dayOfWeek.Count(); i++)
            {
                if (opHours.day.ToLower().Trim() == dayOfWeek[i])
                {
                    if (i == 0)
                    {
                        prevDay = dayOfWeek[6];
                    }
                    else
                    {
                        prevDay = dayOfWeek[i - 1];
                    }
                }
            }
            return(prevDay);
        }