/// <summary> /// Calculates price for the wellness arangement. /// </summary> /// <param name="startHour">When the arangemnt starts</param> /// <param name="hireDate">When the limousine is to be hired.</param> /// <returns>A KeyValuePair where the key is the total price and the value is a list of HourTypes objects.</returns> private KeyValuePair <int, List <HourType> > WellnessPrice(TimeSpan startHour, DateTime hireDate) { if (!Arangements.Any(a => a.GetType().ToString() == typeof(Wellness).ToString())) { throw new DomainException($"Limousine {Name} does not have a wellness arangement."); } else { var ar = Arangements.Single(a => a.GetType().ToString() == typeof(Wellness).ToString()) as Wellness; ar.SetTime(startHour); TimeSpan end = ar.GetEndTime(); DateTime toSetDate = new DateTime(hireDate.Year, hireDate.Month, hireDate.Day, end.Hours, end.Minutes, end.Seconds); if (IsVehicleAvailable(toSetDate)) { AddHireDate(hireDate); } else { throw new DomainException($"Limousine {Name} is niet vrij."); } return(new KeyValuePair <int, List <HourType> >(ar.Price, new List <HourType>())); } }
/// <summary> /// Calculates price for the nightlife arangement. /// </summary> /// <param name="startHour">When the arangemnt starts</param> /// <param name="extraHours">Extra hours to add to the duration of the arangement.</param> /// <param name="hireDate">When the limousine is to be hired.</param> /// <returns>A KeyValuePair where the key is the total price and the value is a list of HourTypes objects.</returns> private KeyValuePair <int, List <HourType> > NightlifePrice(TimeSpan startHour, int?extraHours, DateTime hireDate) { if (!Arangements.Any(a => a.GetType().ToString() == typeof(Nightlife).ToString())) { throw new DomainException($"Limousine {Name} does not have a nightlife arangement."); } else { var ar = Arangements.Single(a => a.GetType().ToString() == typeof(Nightlife).ToString()) as Nightlife; ar.SetTime(startHour, extraHours); var toReturn = ar.GetCalculatedPrice(FirstHourPrice); TimeSpan end = ar.GetEndTime(); DateTime toSetDate = new DateTime(hireDate.Year, hireDate.Month, hireDate.Day, end.Hours, end.Minutes, end.Seconds); if (IsVehicleAvailable(toSetDate)) { AddHireDate(hireDate); } else { throw new DomainException($"Limousine {Name} is niet vrij."); } return(toReturn); } }