예제 #1
0
        private IViewComponentResult GetHolidayView()
        {
            IViewComponentResult HoldiayView = null;

            // check if it is a holiday and if so use the holiday splash screen
            if (HttpContext.Request.Cookies["ItsAHoliday"] == "true")
            {   // check cookies since it is less expensive then running the holiday service
                var todaysHoliday = HttpContext.Request.Cookies["TodaysHoliday"];

                // TODO - J - create all the holiday splash screen models and functionality
                SplashScreenModel holidaySplashScreen = new SplashScreenModel(true);
                return(View("BirthdaySplashScreen", holidaySplashScreen));
            }
            else
            {
                // check for holidays
                IEnumerable <Holiday> holidays;

                //DateTime dayToCheck = DateTime.Parse("12/12/2020"); // TODO - J - remove once testing is done
                //holidays = _holidayService.GetHolidays(dayToCheck); // TODO - J - remove once testing is done

                holidays = _holidayService.GetHolidays();

                if (holidays.Count() > 0)
                {
                    // TODO - J - create all the holiday splash screen model(s) and functionality
                    SplashScreenModel holidaySplashScreen = new SplashScreenModel(true);
                    HoldiayView = View("HolidaySplashScreen", holidaySplashScreen);
                }
            }
            return(HoldiayView);
        }
예제 #2
0
        public async Task <int> GetWorkingDays(DateTime start, DateTime end)
        {
            if (end.Date <= start.Date)
            {
                return(0);
            }

            //shift start date to start day of the week
            var startDate = start.Date.AddDays((int)start.DayOfWeek * -1);
            //shift end date to end day of the week
            var endDate = end.Date.AddHours(24).AddDays((int)DayOfWeek.Saturday - (int)end.DayOfWeek);

            //get total days with full weeks range
            var fullDaysTotal = endDate.Subtract(startDate).TotalDays;
            //get total weekends
            var weekendsTotal = (int)(fullDaysTotal / 7 * 2);

            //get total weekdays
            fullDaysTotal -= weekendsTotal;

            //get offset of start and end dates
            var startOffset = Convert.ToInt16(start.Date.DayOfWeek) - (int)DayOfWeek.Monday;
            var endOffset   = (int)DayOfWeek.Friday - Convert.ToInt16(end.Date.DayOfWeek);

            if (startOffset < 0)
            {
                startOffset = 0;
            }
            if (endOffset < 0)
            {
                endOffset = 0;
            }

            //remove these blocks of code if to and from dates are to be inclusive
            if (start.Date.DayOfWeek != DayOfWeek.Sunday && start.Date.DayOfWeek != DayOfWeek.Saturday)
            {
                startOffset += 1;
            }
            if (end.Date.DayOfWeek != DayOfWeek.Sunday && end.Date.DayOfWeek != DayOfWeek.Saturday)
            {
                endOffset += 1;
            }

            //subtract offset days as a result of shifting the start and end of day
            var totalWorkdays = fullDaysTotal - (startOffset + endOffset);

            //get total holidays
            var totalHolidays = await _holidayService.GetHolidays(start, end);

            totalWorkdays -= totalHolidays
                             .GroupBy(h => h.Date.Date)
                             .Count();

            return(Convert.ToInt32(totalWorkdays));
        }
예제 #3
0
        public bool DetermineTicket(ParkingOffense scanOffense, string scanTag)
        {
            //Note: We should probably move this into an engine like we have for tows.
            //      It could also determine how much the ticket is for, and handle
            //      warning tickets maybe.
            bool isTicketableOffense = true;

            if (scanOffense == ParkingOffense.ExpiredParkingMeter)
            {
                //Is It a holiday?
                var  holidays  = _holidayService.GetHolidays();
                bool isHoliday = holidays.Any(
                    x => x.Date.Month == SystemTime.Now().Month &&
                    x.Date.Day == SystemTime.Now().Day);

                //It is a holiday, we don't charge meters on holiday!
                isTicketableOffense = !isHoliday;
            }

            //We don't want to give a ticket to the same tag, on the same day, for the same thing
            List <ParkingTicketDto> myStateParkingTickets = _myStateParkingAuthority.GetTicketsFromTag(scanTag);

            if (myStateParkingTickets.Any(x =>
                                          x.Offense == scanOffense.ToString() &&
                                          x.DateOfOffense.Month == SystemTime.Now().Month &&
                                          x.DateOfOffense.Day == SystemTime.Now().Day &&
                                          x.DateOfOffense.Year == SystemTime.Now().Year
                                          ))
            {
                isTicketableOffense = false;
            }

            //We Determined they need a parking ticket.
            if (isTicketableOffense)
            {
                _myStateParkingAuthority.IssueParkingTicketDto(scanOffense.ToString(), 30);
            }
            return(isTicketableOffense);
        }
        public ActionResult Index()
        {
            var model = holidayService.GetHolidays();

            return(View(model));
        }