Пример #1
0
        public decimal EndRent(string id)
        {
            Scooter       scooter = GetScooter(id);
            RentedScooter rented  = _rentedScooters.FirstOrDefault(x =>
                                                                   x.ScooterId == id && x.RentalEnd == null && x.RentalStart <= DateTime.UtcNow);

            if (rented == null)
            {
                throw new ScooterIsNotRentedException();
            }

            rented.RentalEnd = DateTime.UtcNow;
            scooter.IsRented = false;

            return(_rentalPriceCalculator.CalculateRentalPrice(rented.RentalStart, rented.RentalEnd,
                                                               scooter.PricePerMinute));
        }
Пример #2
0
        public void StartRent(string id)
        {
            Scooter scooter = GetScooter(id);

            if (scooter == null)
            {
                throw new ScooterNotFoundException();
            }
            else if (scooter.IsRented == true)
            {
                throw new ScooterAlreadyRentedException();
            }
            scooter.IsRented = true;
            _rentedScooters.Add(new RentedScooter
            {
                ScooterId = id, RentalStart = DateTime.UtcNow, PricePerMinute = scooter.PricePerMinute
            });
        }
Пример #3
0
 void Main2()
 {
     Scooter scoot = new Scooter(10);
     Car     car   = (Car)scoot;
 }