Пример #1
0
 public Boat GetBoatById(int boatNumber)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         return(rentBoatContext.Boats.FirstOrDefault(x => x.Id == boatNumber));
     };
 }
Пример #2
0
 public void Add(Boat boat)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         rentBoatContext.Boats.Add(boat);
         rentBoatContext.SaveChanges();
     }
 }
Пример #3
0
 public void Add(Rent rent)
 {
     using (var rentBoatContext = new RentBoatContext())
     {
         rentBoatContext.Rents.Add(rent);
         rentBoatContext.SaveChanges();
     };
 }
Пример #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();
     };
 }
Пример #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();
     };
 }