public bool EditCar(CarType changedCar) { try { using (CarRentEntities db = new CarRentEntities()) { carsType_tbl car = db.carsType_tbl.FirstOrDefault(c => c.CarTypeId == changedCar.CarTypeId); if (car != null) { car.ModelMake = changedCar.ModelMake; car.Model = changedCar.Model; car.ModelName = changedCar.ModelName; car.ModelYear = changedCar.ModelYear; car.ModelBody = changedCar.ModelBody; car.ModelWeightKg = changedCar.ModelWeightKg; car.ModelDoors = changedCar.ModelDoors; car.Gear = changedCar.Gear; db.SaveChanges(); return(true); } return(false); } } catch (Exception) { return(false); } }
public bool Removebranch(string carModel) { try { using (CarRentEntities db = new CarRentEntities()) { carsType_tbl car = db.carsType_tbl.FirstOrDefault(c => c.Model == carModel); if (car != null) { db.carsType_tbl.Remove(car); db.SaveChanges(); return(true); } return(false); } } catch (Exception) { return(false); } }
public CarType GetCar(int id) { using (CarRentEntities db = new CarRentEntities()) { carsType_tbl c = db.carsType_tbl.FirstOrDefault(car => car.CarTypeId == id); if (c != null) { return new CarType { ModelMake = c.ModelMake, Model = c.Model, ModelName = c.ModelName, ModelYear = c.ModelYear, ModelBody = c.ModelBody, ModelWeightKg = c.ModelWeightKg, ModelDoors = c.ModelDoors, Gear = c.Gear } } ; return(null); } }