public async Task <IActionResult> PutAutomobile(int id, Automobile automobile) { if (id != automobile.Id) { return(BadRequest()); } _context.Entry(automobile).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutomobileExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCar(int id, Car car) { if (id != car.Id) { return(BadRequest()); } _context.Entry(car).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBodyType(int id, BodyType bodyType) { if (id != bodyType.Id) { return(BadRequest()); } if (ModelState.IsValid) { _context.Entry(bodyType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BodyTypeExists(id)) { return(NotFound()); } else { throw; } } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "Id,OwnerId,Vin,Model,Make,Year")] Vehicle vehicle) { if (ModelState.IsValid) { db.Entry(vehicle).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vehicle)); }
public ActionResult Edit([Bind(Include = "CarTypeId,Name")] CarType carType) { if (ModelState.IsValid) { db.Entry(carType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(carType)); }
public void Add(Car car) { //_car.Add(car); using (CarsContext context = new CarsContext()) { var addedEntity = context.Entry(car); addedEntity.State = EntityState.Added; context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "Id,Name,State,City")] Owner owner) { if (ModelState.IsValid) { db.Entry(owner).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(owner)); }
public void Delete(Car car) { //_car.Remove(_car.FirstOrDefault(x => x.Id == car.Id)); using (CarsContext context = new CarsContext()) { var deletedEntity = context.Entry(car); deletedEntity.State = EntityState.Deleted; context.SaveChanges(); } }
public static void Update <TEntity>(TEntity entity) where TEntity : class { using (CarsContext context = new CarsContext()) { DbSet <TEntity> dbset = context.Set <TEntity>(); context.Entry(entity).State = EntityState.Modified; context.Database.Log = Console.WriteLine; context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "PointId,Name")] Point point) { if (ModelState.IsValid) { db.Entry(point).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(point)); }
public async Task <ActionResult> Edit([Bind(Include = "id,date,CarModel,price,mileage,tel,seller,description")] Cars cars) // TODO: check if correct (previously was "model") { if (ModelState.IsValid) { db.Entry(cars).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cars)); }
public ActionResult Edit([Bind(Include = "CarId,Name,CarTypeId,Consumption")] Car car) { if (ModelState.IsValid) { db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CarTypeId = new SelectList(db.CarTypes, "CarTypeId", "Name", car.CarTypeId); return(View(car)); }
public ActionResult Edit(Car car) { if (ModelState.IsValid) { db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BrandId = new SelectList(db.Brands, "BrandId", "Name", car.BrandId); return(View(car)); }
public ActionResult Edit([Bind(Include = "TravelId,Name,DirectionId,CarId,TravelDate")] Travel travel) { if (ModelState.IsValid) { db.Entry(travel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CarId = new SelectList(db.Cars, "CarId", "Name", travel.CarId); ViewBag.DirectionId = new SelectList(db.Directions, "DirectionId", "Name", travel.DirectionId); return(View(travel)); }
public ActionResult Edit([Bind(Include = "DirectionId,Name,DepartureId,DestinationId,Distance")] Direction direction) { if (ModelState.IsValid) { db.Entry(direction).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartureId = new SelectList(db.Points, "PointId", "Name", direction.DepartureId); ViewBag.DestinationId = new SelectList(db.Points, "PointId", "Name", direction.DestinationId); return(View(direction)); }
public void Update(Car car) { //Car carToUpdate = _car.FirstOrDefault(x => x.Id == car.Id); //carToUpdate.ModelYear = car.ModelYear; //carToUpdate.Price = car.ModelYear; //carToUpdate.Description = car.Description; //carToUpdate.ColorId = car.ColorId; //carToUpdate.BrandId = car.BrandId; using (CarsContext context = new CarsContext()) { var updatedEntity = context.Entry(car); updatedEntity.State = EntityState.Modified; context.SaveChanges(); } }
public async Task <bool> UpdateCar(Car car) { _carsContext.Entry(await _carsContext.Cars.FirstOrDefaultAsync(x => x.Id == car.Id)).CurrentValues.SetValues(car); return(await _carsContext.SaveChangesAsync().ConfigureAwait(false) > 0); }
public void Update(Car car) { db.Entry(car).State = EntityState.Modified; }
public void Update(Contract contract) { context.Entry(contract).State = EntityState.Modified; }
public void Update(Client client) { context.Entry(client).State = EntityState.Modified; }