Пример #1
0
        public void CalculateSessionsLeft(int totalSessions)
        {
            if (StartDate == null)
            {
                return;
            }

            DateTime start = new DateTime(StartDate.Value.Ticks);
            int      ret   = totalSessions;

            while (ret > 0 && start <= DateTime.Now)
            {
                if (!ShiftedDates.Exists(x => x.Day == start.Day && x.Month == start.Month && x.Year == start.Year))
                {
                    string currentDayName = ((DayOfWeek)start.DayOfWeek).ToString();
                    if (DaysPerWeek.Contains(currentDayName))
                    {
                        ret--;
                    }
                }
                start = start.AddDays(1);
            }

            SessionsLeft = ret;
        }
Пример #2
0
        public void CalculateEndDate(int totalSessions)
        {
            if (StartDate == null)
            {
                return;
            }

            DateTime start = new DateTime(StartDate.Value.Ticks);
            int      count = totalSessions;

            while (count > 0)
            {
                if (!ShiftedDates.Exists(x => x.Day == start.Day && x.Month == start.Month && x.Year == start.Year))
                {
                    string currentDayName = ((DayOfWeek)start.DayOfWeek).ToString();
                    if (DaysPerWeek.Contains(currentDayName))
                    {
                        count--;
                        if (count == 0)
                        {
                            EndDate = start;
                        }
                    }
                }
                start = start.AddDays(1);
            }
        }