示例#1
0
 public void RentCar(CarRent carRent)
 {
     using (var ctx = new AppDbContext()) {
         CarEntity car = ctx.Cars.First(x => x.ID == carRent.CarID);
         car.ClientID = carRent.ClientID;
         ctx.Rents.Add(carRent);
         ctx.SaveChanges();
     }
 }
示例#2
0
 public void ReturnCar(Int32 leaseID)
 {
     using (var ctx = new AppDbContext()) {
         CarRent exisitngRent = ctx.Rents.First(x => x.ID == leaseID);
         ctx.Rents.Remove(exisitngRent);
         CarEntity car = ctx.Cars.First(x => x.ID == exisitngRent.CarID);
         car.ClientID = null;
         ctx.SaveChanges();
     }
 }