public async Task <Rental> StopRental(int id) { Rental r = rentalDBContext.Rentals.Find(id); r.RentalEnd = System.DateTime.Now.AddMinutes(130); r.Customer = await rentalDBContext.Customers.FindAsync(r.CustomerId); r.Bike = await rentalDBContext.Bikes.FindAsync(r.BikeId); r.TotalCosts = CalculateCosts.CalculateTotalCost(r); await rentalDBContext.SaveChangesAsync(); return(r); }
public void CalculateFree() { Bike bike = new Bike(); bike.RentalPriceForFirstHour = 3; bike.RentalPriceForAdditionalHour = 5; bike.ID = 1; Customer customer = new Customer(); customer.ID = 1; Rental r = new Rental(); r.RentalBegin = new DateTime(2018, 02, 14, 8, 15, 0); r.RentalEnd = new DateTime(2018, 02, 14, 8, 25, 0); r.ID = 1; r.Customer = customer; r.CustomerId = customer.ID; r.Bike = bike; r.BikeId = bike.ID; r.TotalCosts = CalculateCosts.CalculateTotalCost(r); Assert.Equal(0, r.TotalCosts, 1); }