Esempio n. 1
0
        private void fillNonVactionDaysFromApiJustIfNotExistAndForNextYears()
        {
            this.contexts = new ScheduleDB();
            this.dbSets   = this.contexts.Set <NonActiveDays>();
            List <NonActiveDays> getNoActiveDays = new List <NonActiveDays>();

            getNoActiveDays = dbSets.AsEnumerable <NonActiveDays>().ToList();
            if (getNoActiveDays.Max(m => m.Date) < new DateTime(2018, 05, 10))
            {
                var publicHolidays = DateSystem.GetPublicHoliday(CountryCode.IS, new DateTime(2018, 05, 11, 0, 0, 0), new DateTime(2018, 05, 20, 0, 0, 0));
                for (int i = 0, orderNumber = 1; i < publicHolidays.Count() && orderNumber <= 17; orderNumber++)
                {
                    if (getNoActiveDays.FindIndex(day => day.Date < publicHolidays.ElementAt(i).Date) >= 0)
                    {
                        NonActiveDays day = new NonActiveDays();
                        day.Date        = publicHolidays.ElementAt(i).Date;
                        day.OrderNumber = orderNumber;
                        day.Reason      = "���� ������ ������";
                        dbSets.Add(day);
                        contexts.SaveChanges();
                    }
                    if (orderNumber == 17)
                    {
                        orderNumber = 0;
                        i++;
                    }
                }
            }
        }
Esempio n. 2
0
        private void fillNonVactionDaysFromApi(DateTime startDate, DateTime endDate)
        {
            this.contexts = new ScheduleDB();
            this.dbSets   = this.contexts.Set <NonActiveDays>();
            var publicHolidays = DateSystem.GetPublicHoliday(CountryCode.IS, startDate, endDate);

            for (int i = 0, orderNumber = 1; i < publicHolidays.Count() && orderNumber <= 17; orderNumber++)
            {
                NonActiveDays day = new NonActiveDays();
                day.Date        = publicHolidays.ElementAt(i).Date;
                day.OrderNumber = orderNumber;
                day.Reason      = "���� ������ ������";
                dbSets.Add(day);
                contexts.SaveChanges();
                if (orderNumber == 17)
                {
                    orderNumber = 0;
                    i++;
                }
            }
        }