public override double TotalCosts(string tariffKey, PhoneConsumption consumption) { Tariff tariff = DalFactory.CreateTariffDao(database).FindById(tariffKey); if (tariff == null) { throw new ArgumentException(string.Format("Invalid tariff {0}.", tariffKey)); } double costs = tariff.BasicFee; IRateDao rateDao = DalFactory.CreateRateDao(database); foreach (ZoneConsumption zc in consumption.ZoneConsumptions) { Rate rate = rateDao.FindById(tariffKey, zc.ZoneId); if (rate == null) { throw new ArgumentException(string.Format("Invalid zone {0}.", zc.ZoneId)); } costs += zc.PeakDuration * rate.PeakRate + zc.OffPeakDuration * rate.OffPeakRate; } return(costs); }
public RateService(IRateDao rateDao, IUserDao userDao) { _rateDao = rateDao; _userDao = userDao; }
public RateLogic() { this.productDao = DaoProvider.ProductDao; this.rateDao = DaoProvider.RateDao; this.validator = new Validator(); }