public void AddClient(PhoneNumber phoneNumber, ITariff tariff)
 {
     _tariffsMap.Add(phoneNumber, tariff);
     _canChangeTariffMap.Add(phoneNumber, true);
     _callsMap.Add(phoneNumber, new List<CallInfo>());
     _debtMap.Add(phoneNumber, 0);
 }
        public ITerminal SignContract(ITariff tariff)
        {
            ITerminal t1 = _station.GetPreparedTerminal();

            if (t1 != null)
            {
                _billingSystem.AddClient(t1.PhoneNumber, tariff);
            }

            return t1;
        }
        public bool TryChangeTariff(PhoneNumber phoneNumber, ITariff newTariff)
        {
            if (_tariffsMap[phoneNumber] == newTariff)
                return false;

            if (_canChangeTariffMap[phoneNumber])
            {
                _tariffsMap[phoneNumber] = newTariff;
                _canChangeTariffMap[phoneNumber] = false;
                return true;
            }

            return false;
        }
Example #4
0
 public bool SetTariffForTerminal(PhoneNumber number, ITariff tariff)
 {
     bool isChanged = false;
     if (!_tariffMaping.Keys.Contains(number)) { _tariffMaping.Add(number, tariff); isChanged = true; }
     else
     {
         if ((DateTime.Now -_tariffMaping[number].DateOfSet).Days >= DateTime.DaysInMonth(_tariffMaping[number].DateOfSet.Year, (_tariffMaping[number].DateOfSet).Month))
         {
             _tariffMaping[number] = tariff;
             isChanged = true;
         }
         else { isChanged = false; }
     }
     if (isChanged) { OnTerminalChangedTariff(this, number); }
     return isChanged;
 }
 public bool TryChangeTariff(PhoneNumber phoneNumber, ITariff newTariff)
 {
     return _billingSystem.TryChangeTariff(phoneNumber, newTariff);
 }