Ejemplo n.º 1
0
 /// <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>()));
     }
 }
Ejemplo n.º 2
0
 /// <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);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Checks if an arangements is available for this limousine.
        /// </summary>
        /// <param name="arangementName">Arangement to check.</param>
        /// <returns>>A boolean representing if an arangements is available. If true it is available.</returns>
        public bool HasArangement(string arangementName)
        {
            switch (arangementName)
            {
            case "Wellness":
            {
                if (Arangements.Any(a => a.GetType().ToString() == typeof(Wellness).ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "Business":
            {
                if (Arangements.Any(a => a.GetType().ToString() == typeof(Business).ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "Airport":
            {
                if (Arangements.Any(a => a.GetType().ToString() == typeof(Airport).ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "Wedding":
            {
                if (Arangements.Any(a => a.GetType().ToString() == typeof(Wedding).ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "Nightlife":
            {
                if (Arangements.Any(a => a.GetType().ToString() == typeof(Nightlife).ToString()))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            default:
                return(false);
            }
        }