/// <summary> /// Gets the current tariff. /// </summary> /// <returns></returns> public ITariffPlan GetCurrentTariff() { TariffPlanRecord currentTariffRecord = _tariffPlanHistory.LastOrDefault(); if (currentTariffRecord != null) { return(currentTariffRecord.TariffPlan); } return(null); }
/// <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); }