Exemple #1
0
        public void StartRent(string scooterId)
        {
            var scooter = ScooterService.GetScooterById(scooterId);

            if (scooter.IsRented)
            {
                throw new ScooterIsRented("The scooter is being rented.");
            }

            scooter.IsRented = true;
            RentHistory.Add(new RentedUnit(_transId++, scooterId, DateTime.Now, scooter.PricePerMinute));
        }
Exemple #2
0
        public void EndRent(string scooterId)
        {
            foreach (var t in RentHistory)
            {
                if (t.StartTime == t.EndTime && t.ScooterId == scooterId)
                {
                    ScooterService.GetScooterById(scooterId).IsRented = false;
                    t.EndTime    = DateTime.Now;
                    t.TotalPrice = Calculations.CalculatePrice(t);
                    return;
                }
            }

            throw new ScooterIsNotRented("That scooter has not been rented.");
        }