public void EditCar(Car car) { using (var db = new CarSalesDb()) { db.Entry(car).State = EntityState.Modified; db.SaveChanges(); } }
public void CreateCar(Car car) { using (var db = new CarSalesDb()) { db.Cars.Add(car); db.SaveChanges(); } }
public void SaveEnquiry(Enquiry enquiry) { using (var db = new CarSalesDb()) { db.Enquiries.Add(enquiry); db.SaveChanges(); } }
public void DeleteCar(int carId) { using (var db = new CarSalesDb()) { var carToRemove = db.Cars.FirstOrDefault(c => c.Id == carId); db.Cars.Remove(carToRemove); db.SaveChanges(); } }
public void CreateCars(List <Car> cars) { using (var db = new CarSalesDb()) { foreach (var car in cars) { db.Cars.Add(car); db.SaveChanges(); } } }