public virtual bool GetIsBlackout(DateTime dateTime)
        {
            if (BlackoutDays == null || !BlackoutDays.Any())
            {
                return(false);
            }

            var blackoutDay =
                this.BlackoutDays.FirstOrDefault(i =>
                                                 i.Year == dateTime.Year &&
                                                 i.Month == dateTime.Month &&
                                                 i.Day == dateTime.Day);

            return(blackoutDay.Year != 0001);
        }
Exemplo n.º 2
0
        public IActionResult BlackoutDay(BlackoutDayViewModel model)
        {
            if (!ModelState.IsValid || checkForExisting.GetBlackoutDay(context, model.BlackoutDate.ToShortDateString()))
            {
                return(View(model));
            }

            BlackoutDays blackout = new BlackoutDays
            {
                DateBlackedOut = model.BlackoutDate
            };

            context.Add(blackout);
            context.SaveChanges();
            return(Redirect("/"));
        }
Exemplo n.º 3
0
        private void LoadMonths()
        {
            if (BlackoutDays == null)
            {
                return;
            }

            for (DateTime i = Min; i <= Max;)
            {
                var dateTime = new DateTime(i.Year, i.Month, 1);

                var dateTimeModel = new RTDCalendarViewToggleButton()
                {
                    DateTime             = dateTime,
                    IsBlackout           = true,
                    IsSelected           = false,
                    IsBlackSelectionMode = false,
                    IsDisabled           = false,
                    IsToday = false
                };

                Months.Add(new CalendarDays <RTDCalendarViewToggleButton>(dateTimeModel, BlackoutDays.ToArray()));
                i = i.AddMonths(1);
            }
        }