public IHttpActionResult Puttbl_Airports(string id, tbl_Airports tbl_Airports) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_Airports.IATA_code) { return(BadRequest()); } db.Entry(tbl_Airports).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tbl_AirportsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Posttbl_Airports(tbl_Airports tbl_Airports) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tbl_Airports.Add(tbl_Airports); try { db.SaveChanges(); } catch (DbUpdateException) { if (tbl_AirportsExists(tbl_Airports.IATA_code)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = tbl_Airports.IATA_code }, tbl_Airports)); }
public IHttpActionResult Deletetbl_Airports(string id) { tbl_Airports tbl_Airports = db.tbl_Airports.Find(id); if (tbl_Airports == null) { return(NotFound()); } db.tbl_Airports.Remove(tbl_Airports); db.SaveChanges(); return(Ok(tbl_Airports)); }