예제 #1
0
        public ParkingTransaction CalculateParkingRate(Patron patron)
        {
            ParkingRateCode parkingRateCode = _parkingRateDecisionTree.Evaluate(patron);
            var             rate            = _repository.GetParkingRate(parkingRateCode);

            return(new ParkingTransaction(patron, rate));
        }
예제 #2
0
        private IParkingRate RetriveExistingParkingRate(ParkingRateCode parkingRateCode)
        {
            IParkingRate parkingRate;

            _parkingRatesMap.TryGetValue(parkingRateCode, out parkingRate);
            return(parkingRate);
        }
예제 #3
0
        public IParkingRate GetParkingRate(ParkingRateCode parkingRateCode)
        {
            if (Enum.IsDefined(typeof(ParkingRateCode), parkingRateCode) == false)
            {
                throw new Exception(String.Format("Unable to create a new parking rate with code: {0}", parkingRateCode));
            }

            return(_parkingRatesFactory.CreateParkingRate(parkingRateCode));
        }
예제 #4
0
        // created the function as virtual to have an extension point without overriding the
        // entire class implementation, only the location creation method.
        public virtual IParkingRate CreateParkingRate(ParkingRateCode parkingRateCode)
        {
            IParkingRate parkingRate = RetriveExistingParkingRate(parkingRateCode);

            if (parkingRate != null)
            {
                return(parkingRate);
            }

            parkingRate = GenerateParkingRateObject(parkingRateCode);
            AddCreatedParkingRate(parkingRateCode, parkingRate);
            return(parkingRate);
        }
예제 #5
0
        protected virtual IParkingRate GenerateParkingRateObject(ParkingRateCode parkingRateCode)
        {
            IParkingRate parkingRate = null;

            switch (parkingRateCode)
            {
            case ParkingRateCode.EarlyBird:
            {
                parkingRate = CreateEarlyBirdRateObject();
                break;
            }

            case ParkingRateCode.NightRate:
            {
                parkingRate = CreateNightRateObject();

                break;
            }

            case ParkingRateCode.WeekendRate:
            {
                parkingRate = CreateWeekendRateObject();
                break;
            }

            case ParkingRateCode.StandardHourRate:
            case ParkingRateCode.StandardCalendarDayRate:
            {
                parkingRate = CreateStandardRateObject();
                break;
            }

            default:
            {
                parkingRate = CreateStandardRateObject();
                break;
            }
            }

            return(parkingRate);
        }
예제 #6
0
 public string RetriveDisplayAttribute(ParkingRateCode code)
 {
     return(typeof(ParkingRateCode).GetEnumDescription((int?)code));
 }
예제 #7
0
 private void AddCreatedParkingRate(ParkingRateCode parkingRateCode, IParkingRate parkingRateObject)
 {
     _parkingRatesMap.Add(parkingRateCode, parkingRateObject); // add for next time
 }
        public Type ReturnCorrectParkingObjectByCode(ParkingRateCode code)
        {
            var rate = _repo.GetParkingRate(code);

            return(rate.GetType());
        }