public async Task <IActionResult> PutCar([FromRoute] int id, [FromBody] Car car) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } 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,Model,MaxSpeed")] CarCore carCore) { if (ModelState.IsValid) { _context.Add(carCore); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(carCore)); }