public async Task <IActionResult> PutVehicle([FromRoute] int id, [FromBody] Vehicle vehicle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vehicle.VehicleID) { return(BadRequest()); } _context.Entry(vehicle).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSpecial([FromRoute] int id, [FromBody] Special special) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != special.Special_ID) { return(BadRequest()); } _context.Entry(special).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpecialExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Post([FromBody] Contact value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _context.Contact.Add(value); await _context.SaveChangesAsync(); } catch (Exception ex) { Console.WriteLine(ex); throw ex; } return(Ok()); }