コード例 #1
0
        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);
        }
コード例 #2
0
 public RateService(IRateDao rateDao, IUserDao userDao)
 {
     _rateDao = rateDao;
     _userDao = userDao;
 }
コード例 #3
0
ファイル: RateLogic.cs プロジェクト: KVeronika/EPAMXT2016_3
 public RateLogic()
 {
     this.productDao = DaoProvider.ProductDao;
     this.rateDao    = DaoProvider.RateDao;
     this.validator  = new Validator();
 }