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> Create([Bind("Id,BrandName,ModelName,YearOfConstruction,Idnummer")] CarSet carSet) { if (ModelState.IsValid) { _context.Add(carSet); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(carSet)); }
public async Task <bool> SaveAll(Car entity) { return(await _context.SaveChangesAsync() > 0); }