Exemple #1
0
        private List <Travel> FindTravelsTodayAfterCurrentHour(List <Travel> pTravelList, DateTime date)
        {
            var scheduleMng    = new ScheduleManager();
            var day            = GetWeekDay(date);
            var minutesOfToday = (date.Hour * 60) + date.Minute;

            List <Travel> filteredList = pTravelList.Where(travel => (travel.Schedule.Day.Equals(day) && travel.Schedule.DepartHourAsMinutes >= minutesOfToday)).ToList();

            filteredList = filteredList.OrderBy(travel => (travel.Schedule.DepartHourAsMinutes)).ToList();

            return(filteredList);
        }
Exemple #2
0
        private string GetWeekDay(DateTime date)
        {
            var scheduleMng  = new ScheduleManager();
            var day          = "" + (1 + (int)date.DayOfWeek);
            var fakeSchedule = new Schedule
            {
                Day = day
            };

            day = scheduleMng.GetDayByName(fakeSchedule);

            return(day);
        }
Exemple #3
0
 public void Update(Travel travel)
 {
     try
     {
         Schedule ScheduleInfoBeforeUpdate = new ScheduleManager().RetrieveById(new Schedule {
             IdSchedule = travel.Schedule.IdSchedule
         });
         VerifyIsValidSchedule(travel);
         ValidateNewTravelInfo(travel, ScheduleInfoBeforeUpdate);
         CrudFactory.Update(travel);
     }
     catch (Exception bex)
     {
         ExceptionManager.GetInstance().Process(bex);
     }
 }
Exemple #4
0
        private List <Travel> FindNextTravels(List <Travel> pTravelList, DateTime date, string pBreakDay)
        {
            date = date.AddDays(1);

            List <Travel> filteredList = null;
            var           scheduleMng  = new ScheduleManager();
            var           day          = GetWeekDay(date);

            if (!pBreakDay.Equals(day))
            {
                filteredList = pTravelList.Where(travel => (travel.Schedule.Day.Equals(day))).ToList();
                filteredList = filteredList.OrderBy(travel => (travel.Schedule.DepartHourAsMinutes)).ToList();

                if (filteredList?.Count == 0)
                {
                    FindNextTravels(pTravelList, date, pBreakDay);
                }
            }

            return(filteredList);
        }