public ParkingTransaction CalculateParkingRate(Patron patron) { ParkingRateCode parkingRateCode = _parkingRateDecisionTree.Evaluate(patron); var rate = _repository.GetParkingRate(parkingRateCode); return(new ParkingTransaction(patron, rate)); }
private IParkingRate RetriveExistingParkingRate(ParkingRateCode parkingRateCode) { IParkingRate parkingRate; _parkingRatesMap.TryGetValue(parkingRateCode, out parkingRate); return(parkingRate); }
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)); }
// 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); }
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); }
public string RetriveDisplayAttribute(ParkingRateCode code) { return(typeof(ParkingRateCode).GetEnumDescription((int?)code)); }
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()); }