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)); }
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 }); }
void Main2() { Scooter scoot = new Scooter(10); Car car = (Car)scoot; }