public bool edit(Car car) { using (Software_FactoryEntities context = new Software_FactoryEntities()) { try { CarEntity aux = context.Car.Single(x => x.car_id == car.car_id); aux.company = car.company; aux.name = car.name; aux.stock = car.stock; return true; } catch (Exception) { return false; } } }
public bool create(Car car) { using (Software_FactoryEntities context = new Software_FactoryEntities()) { try { CarEntity aux = new CarEntity(); aux.company = car.company; aux.name = car.name; aux.stock = car.stock; context.Car.Add(aux); context.SaveChanges(); return true; } catch (Exception) { return false; } } }
public bool delete(Car car) { using (Software_FactoryEntities context = new Software_FactoryEntities()) { try { int n_id = Convert.ToInt32(car.car_id); CarEntity aux = context.Car.Single(x => x.car_id == n_id); context.Car.Remove(aux); context.SaveChanges(); return true; } catch (Exception) { return false; } } }