public void Delete(Car entity) { using (CarRentalDBContext context = new CarRentalDBContext()) { var deletedCar = context.Entry(entity); deletedCar.State = EntityState.Deleted; context.SaveChanges(); } }
public void Update(Car entity) { using (CarRentalDBContext context = new CarRentalDBContext()) { var updatedCar = context.Entry(entity); updatedCar.State = EntityState.Modified; context.SaveChanges(); } }
public void Add(Car entity) { using (CarRentalDBContext context = new CarRentalDBContext()) { var addedCar = context.Entry(entity); addedCar.State = EntityState.Added; context.SaveChanges(); } }