Пример #1
0
 public void EditCar(Car car)
 {
     using (var db = new CarSalesDb())
     {
         db.Entry(car).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
Пример #2
0
 public void CreateCar(Car car)
 {
     using (var db = new CarSalesDb())
     {
         db.Cars.Add(car);
         db.SaveChanges();
     }
 }
Пример #3
0
 public void SaveEnquiry(Enquiry enquiry)
 {
     using (var db = new CarSalesDb())
     {
         db.Enquiries.Add(enquiry);
         db.SaveChanges();
     }
 }
Пример #4
0
 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();
     }
 }
Пример #5
0
 public void CreateCars(List <Car> cars)
 {
     using (var db = new CarSalesDb())
     {
         foreach (var car in cars)
         {
             db.Cars.Add(car);
             db.SaveChanges();
         }
     }
 }