Esempio n. 1
0
        public void ScheduleOccupation(CarOccupation occupation)
        {
            if (!IsFreeOnPeriod(occupation.Period))
            {
                throw new CarIsUnvailableException("Can not schedule occupation on busy period");
            }

            _occupations.Add(occupation);
        }
Esempio n. 2
0
        public CarOccupation GetLastOccupationOfType(OccupationStatus occupationStatus)
        {
            CarOccupation lastOccupation = null;

            foreach (var occupation in _occupations)
            {
                if (occupation.OccupationStatus == occupationStatus)
                {
                    lastOccupation = occupation;
                }
            }

            return(lastOccupation);
        }
Esempio n. 3
0
        private int CountRentsAfterLastCheckup(CarOccupation lastCheckup)
        {
            var rentsCount = 0;

            if (lastCheckup == null)
            {
                return(rentsCount);
            }

            foreach (var occupation in CarSchedule.Occupations)
            {
                if (occupation.OccupationStatus == OccupationStatus.Rented &&
                    occupation.Period.IsLaterThan(lastCheckup.Period))
                {
                    rentsCount++;
                }
            }

            return(rentsCount);
        }