Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 3
0
 public void AddDefect(Defect defect)
 {
     using (var context = new RentalContext())
     {
         var defectDto = ModelToDto(defect);
         context.Defects.Add(defectDto);
         context.SaveChanges();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 6
0
        public void AddRental(Rental rental)
        {
            var rentalDto = ModeltoDto(rental);

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