예제 #1
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);
        }
예제 #2
0
        static void Main(string[] args)
        {
            ParkingTicketCalculator ptc = new ParkingTicketCalculator();

            ParkingOffense myOffense = ParkingOffense.UnknownParkingOffense;

            //Todo: We have to validate user Input. We could pass ham as an argument
            //      and it shouldn't throw an exception. Maybe consider moving
            //      the parsing to business logic so that we don't have to do this
            //      for the front end.
            if (Enum.IsDefined(typeof(ParkingOffense), Convert.ToInt32(args[1])))
            {
                myOffense = (ParkingOffense)Convert.ToInt32(args[1]);
            }


            string tag = args[0];

            //Todo: Probably should have verification on this so that we fail safely
            //      when someone enters ham as a zip.
            int zip = Convert.ToInt32(args[2]);

            Console.WriteLine("Parking Offense: " + myOffense.ToString());
            Console.WriteLine("Tag:             " + tag);
            Console.WriteLine("Zip Code:        " + zip);
            Console.WriteLine("Scan Started at: " + DateTime.Now.ToString());

            string result = ptc.ScanForOffense(new ScanInformation {
                Offense = myOffense, Tag = tag, zipCode = zip
            });

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(result);
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Scan Done at:    " + DateTime.Now.ToString());
            Console.WriteLine("Press any key to close.");
            Console.ReadKey();
        }