Beispiel #1
0
        private void SetupPeriods()
        {
            DateTime forDate = _startDateTime.Date;

            while (forDate <= DateTime.Today)
            {
                if (_service.GetDayPeriod(forDate) == null)
                {
                    _service.CreateDayPeriod(forDate);
                }

                DateTime weekStart = DateTimeHelper.GetWeekStart(forDate);
                if (_service.GetWeekPeriod(weekStart) == null)
                {
                    _service.CreateWeekPeriod(forDate);
                }

                if (_service.GetMonthPeriod(forDate) == null)
                {
                    _service.CreateMonthPeriod(forDate);
                }

                forDate = forDate.AddDays(1);
            }
            _context.SaveChanges();
        }