public bool UpdateCar(DAL.Car car) { db.Entry(car).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(true); }
// This method will Update a car public void PUT(int id, Car car) { using (CarDBEntities entities = new CarDBEntities()) { var updateCar = entities.Cars.Find(id); updateCar.Make = car.Make; updateCar.Model = car.Model; updateCar.Colour = car.Colour; updateCar.YearOfManufacturer = car.YearOfManufacturer; entities.Entry(updateCar).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); /* * Postman app to test with JSON snippet: * { * "Make": "Peugoet update", * "Model": "3008 update", * "Colour": "Black update", * "YearOfManufacturer": 2000 * } */ } }