Пример #1
0
        public static bool isClosingSoon(Indawo indawo)
        {
            var now      = DateTime.Now;
            var dayToday = now.DayOfWeek;
            var opHours  = indawo.oparatingHours.FirstOrDefault(x => x.day.ToLower()
                                                                == dayToday.ToString().ToLower());

            if (opHours != null)
            {
                var closingHours = opHours.closingHour.TimeOfDay;
                var timeNow      = DateTime.Now.TimeOfDay;
                var timeLeft     = opHours.closingHour.TimeOfDay.Subtract(timeNow);
                if (closingHours.ToString().First() == '0')
                {
                    timeLeft = getTimeLeft(closingHours, now, timeLeft);
                }
                var anHour = new TimeSpan(1, 0, 0);

                if (timeLeft <= anHour && timeLeft > new TimeSpan(0, 0, 0))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
Пример #2
0
        public static bool assignSatus(Indawo indawo)
        {
            var dateToday = DateTime.Now;
            var nextDay   = DateTime.Now.AddDays(1);
            var dayToday  = dateToday.DayOfWeek;

            foreach (var item in indawo.oparatingHours)
            {
                item.closingHour = new DateTime(dateToday.Year, dateToday.Month, dateToday.Day, item.closingHour.Hour,
                                                item.closingHour.Minute, item.closingHour.Second);
                if (item.closingHour.TimeOfDay.ToString().First() == '0')
                {
                    item.closingHour = new DateTime(nextDay.Year, nextDay.Month, nextDay.Day, item.closingHour.Hour,
                                                    item.closingHour.Minute, item.closingHour.Second);
                }
                item.openingHour = new DateTime(dateToday.Year, dateToday.Month, dateToday.Day, item.openingHour.Hour,
                                                item.openingHour.Minute, item.openingHour.Second);
            }
            var opHours = indawo.oparatingHours.FirstOrDefault(x => x.day.ToLower()
                                                               == dayToday.ToString().ToLower());

            if (opHours == null)
            {
                return(false);
            }
            else
            {
                return(openOrClosed(opHours, indawo));
            }
        }
Пример #3
0
 private static OperatingHours getDayBeforeOpHour(string daybefore, Indawo indawo)
 {
     foreach (var item in indawo.oparatingHours)
     {
         if (item.day.ToLower().Trim() == daybefore)
         {
             return(item);
         }
     }
     return(null);
 }
Пример #4
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);
     }
 }
Пример #5
0
        internal static void getOpratingHoursStr(Indawo item)
        {
            var           str            = "";
            List <string> retStr         = new List <string>();
            int           i              = 0;
            var           operatingHours = item.oparatingHours;

            foreach (var opHour in operatingHours)
            {
                i++;
                str += opHour.day + " | " + opHour.openingHour.ToString().Split(' ')[1].Substring(0, 5) + " to "
                       + opHour.closingHour.ToString().Split(' ')[1].Substring(0, 5) + " " + opHour.occation;
                item.operatingHoursStr.Add(str);
                str = "";
            }
        }
Пример #6
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);
        }
Пример #7
0
 public static string getClosedStatus(Indawo location)
 {
     if (location.open == false && location.closingSoon == false && location.openingSoon == false)
     {
         return("CLOSED");
     }
     else if (location.open == true && location.closingSoon == true)
     {
         return("CLOSING SOON");
     }
     else if (location.open == false && location.openingSoon == true)
     {
         return("OPENING SOON");
     }
     else if (location.open == true && location.closingSoon == false)
     {
         return("OPEN");
     }
     return("");
 }
Пример #8
0
 public static string getLocationInfo(Indawo location)
 {
     if (location.distance > 1 && location.entranceFee > 0)
     {
         return(location.distance + "KM | " + "R" + location.entranceFee);
     }
     else if (location.distance <= 1 && location.entranceFee == 0)
     {
         return("LESS THAN A KM AWAY | " + "FREE ");
     }
     else if (location.distance <= 1 && location.entranceFee != 0)
     {
         return("LESS THAN A KM AWAY | " + "R" + location.entranceFee);
     }
     else if (location.distance > 1 && location.entranceFee == 0)
     {
         return(location.distance + "KM | " + "FREE");
     }
     else
     {
         return("");
     }
 }