Exemple #1
0
 public Boat GetBoatById(int boatNumber)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         return(rentBoatContext.Boats.FirstOrDefault(x => x.Id == boatNumber));
     };
 }
Exemple #2
0
 public void Add(Boat boat)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         rentBoatContext.Boats.Add(boat);
         rentBoatContext.SaveChanges();
     }
 }
Exemple #3
0
 public void Add(Rent rent)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         rentBoatContext.Rents.Add(rent);
         rentBoatContext.SaveChanges();
     };
 }
Exemple #4
0
 public void MarkAsRenturned(int boatNumber, DateTime endTime)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         var rent = rentBoatContext.Rents.FirstOrDefault(x => x.Boat.Id == boatNumber && x.EndTime == null);
         rent.EndTime = endTime;
         rentBoatContext.SaveChanges();
     };
 }
Exemple #5
0
 public void RemoveBoatById(int boatId)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         Boat boat = new Boat()
         {
             Id = boatId
         };
         rentBoatContext.Boats.Attach(boat);
         rentBoatContext.Boats.Remove(boat);
         rentBoatContext.SaveChanges();
     };
 }