public Car UpdateCar(Car carToUpdate) { _carShopContext.Attach(carToUpdate).State = EntityState.Modified; _carShopContext.Entry(carToUpdate.CarDetails).State = EntityState.Modified; _carShopContext.Entry(carToUpdate.CarAccessories).State = EntityState.Modified; _carShopContext.Entry(carToUpdate.CarSpecs).State = EntityState.Modified; _carShopContext.Entry(carToUpdate).Collection(c => c.PictureLinks).IsModified = true; _carShopContext.SaveChanges(); return(carToUpdate); }
public async Task <IActionResult> PutTool(int id, Tool tool) { if (id != tool.Id) { return(BadRequest()); } _context.Entry(tool).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ToolExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Update(CarBrands carBrand) { using (var context = new CarShopContext()) { var entity = context.CarBrands.Find(carBrand.Id); context.Entry(entity).CurrentValues.SetValues(carBrand); context.SaveChanges(); } }
public ActionResult Edit([Bind(Include = "ID,Company,Model,CC,Price")] Car car) { if (ModelState.IsValid) { db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(car)); }
public void Edit(User entity) { db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); }