예제 #1
0
 public void RentScooter(int scooterId)
 {
     using (var context = new RentalContext())
     {
         var scooter = context.Scooters.First(s => s.ScooterId == scooterId);
         scooter.Rented = true;
         context.SaveChanges();
     }
 }
예제 #2
0
 public void DefectResolved(int scooterId)
 {
     using (var context = new RentalContext())
     {
         var scooter = context.Scooters.First(s => s.ScooterId == scooterId);
         scooter.Rented = false;
         context.SaveChanges();
     }
 }
예제 #3
0
 public void AddDefect(Defect defect)
 {
     using (var context = new RentalContext())
     {
         var defectDto = ModelToDto(defect);
         context.Defects.Add(defectDto);
         context.SaveChanges();
     }
 }
예제 #4
0
 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();
     }
 }
예제 #5
0
 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();
     }
 }
예제 #6
0
        public void AddRental(Rental rental)
        {
            var rentalDto = ModeltoDto(rental);

            using (var context = new RentalContext())
            {
                context.Rentals.Add(rentalDto);
                context.SaveChanges();
            }
        }