Ejemplo n.º 1
0
        /// <summary>
        /// Gets the current tariff.
        /// </summary>
        /// <returns></returns>
        public ITariffPlan GetCurrentTariff()
        {
            TariffPlanRecord currentTariffRecord = _tariffPlanHistory.LastOrDefault();

            if (currentTariffRecord != null)
            {
                return(currentTariffRecord.TariffPlan);
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Changes the tariff.
        /// </summary>
        /// <param name="newTariff">The new tariff.</param>
        /// <returns></returns>
        public bool ChangeTariff(ITariffPlan newTariff)
        {
            TariffPlanRecord currentTariffRecord = _tariffPlanHistory.LastOrDefault();

            if (currentTariffRecord != null)
            {
                if (currentTariffRecord.StartDate.Year == StaticTime.CurrentTime.Year &&
                    currentTariffRecord.StartDate.Month == StaticTime.CurrentTime.Month)
                {
                    return(false);
                }
                currentTariffRecord.EndDate = StaticTime.CurrentTime;
            }

            TariffPlanRecord newTariffRecord = new TariffPlanRecord();

            newTariffRecord.TariffPlan = newTariff;
            newTariffRecord.StartDate  = StaticTime.CurrentTime;
            _tariffPlanHistory.Add(newTariffRecord);
            return(true);
        }