public void RentScooter(int scooterId) { using (var context = new RentalContext()) { var scooter = context.Scooters.First(s => s.ScooterId == scooterId); scooter.Rented = true; context.SaveChanges(); } }
public void DefectResolved(int scooterId) { using (var context = new RentalContext()) { var scooter = context.Scooters.First(s => s.ScooterId == scooterId); scooter.Rented = false; context.SaveChanges(); } }
public void AddDefect(Defect defect) { using (var context = new RentalContext()) { var defectDto = ModelToDto(defect); context.Defects.Add(defectDto); context.SaveChanges(); } }
public void DefectResolved(int scooterId) { using (var context = new RentalContext()) { var defect = context.Defects.First(d => d.ScooterId == scooterId && d.Resolved == false); defect.Resolved = true; context.SaveChanges(); } }
public void EndRental(Guid userId, int scooterId, DateTime now) { using (var context = new RentalContext()) { var rental = context.Rentals.First(r => r.UserId == userId.ToString() && r.ScooterId == scooterId && r.RentalEnd == null); rental.RentalEnd = now; context.SaveChanges(); } }
public void AddRental(Rental rental) { var rentalDto = ModeltoDto(rental); using (var context = new RentalContext()) { context.Rentals.Add(rentalDto); context.SaveChanges(); } }