public bool CreateCar(DAL.Car cars, string user) { cars.UName = user; db.Cars.Add(cars); db.SaveChanges(); return(true); }
public CarReservation InsertCarReservation(int id_vehiculo, int id_cliente, string nombre, string apellido, string telefono, string correo, string horaentrada, string horasalida, string fechaentrada, string fechasalida, string lugar) { CarReservation reservation = new CarReservation(); using (CarDBEntities dc = new CarDBEntities()) { reservation.idVehiculo = id_vehiculo; reservation.idCliente = id_cliente; reservation.nombre = nombre; reservation.apellidos = apellido; reservation.telefono = telefono; reservation.correo = correo; reservation.horaentrada = horaentrada; reservation.horasalida = horasalida; reservation.fechaentrada = fechaentrada; reservation.fechasalida = fechasalida; reservation.lugar = lugar; dc.Configuration.ValidateOnSaveEnabled = false; dc.CarReservations.Add(reservation); dc.SaveChanges(); } return(null); }
// This method will Delete a car public string Delete(int id) { using (CarDBEntities entities = new CarDBEntities()) { var car = entities.Cars.Find(id); entities.Cars.Remove(car); entities.SaveChanges(); return(string.Format("Car with ID={0} is deleted", id)); } }
public HttpResponseMessage Post(Car car) { try { db.Cars.Add(car); if (db.SaveChanges() > 1) { return(Request.CreateResponse(HttpStatusCode.OK, "Araç Eklendi")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Araç Ekleme Başarısız")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex.Message)); } }
// This method will Add a new car public void POST(Car car) { using (CarDBEntities entities = new CarDBEntities()) { entities.Cars.Add(car); entities.SaveChanges(); /* * Postman app to test with JSON snippet: * { * "Make": "Peugoet", * "Model": "3008", * "Colour": "Black", * "YearOfManufacturer": 2011 * } */ } }
public void AddCar(Car car) { using (CarDBEntities CarDB = new CarDBEntities()) { var newCar = new EFCar(); { newCar.Id = car.Id; newCar.Make = car.Make; newCar.Model = car.Model; newCar.Year = car.Year; newCar.ImageUrl = car.ImageUrl; newCar.Title = car.Title; newCar.Description = car.Description; newCar.Price = (decimal)car.Price; }; CarDB.EFCars.Add(newCar); CarDB.SaveChanges(); } }
// 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 * } */ } }
public void InsertCustomer(Customer customer) { _contex.Customers.Add(customer); _contex.SaveChanges(); }
public void SaveChanges() { _contex.SaveChanges(); }