public async Task <IHttpActionResult> PostFlightPlace(FlightPlace flightPlace) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.FlightPlaces.Add(flightPlace); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (FlightPlaceExists(flightPlace.numPlace)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = flightPlace.numPlace }, flightPlace)); }
public async Task <IHttpActionResult> PutFlightPlace(int id, FlightPlace flightPlace) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != flightPlace.numPlace) { return(BadRequest()); } db.Entry(flightPlace).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FlightPlaceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostPlace(PlaceData data) { FlightPlace place = new FlightPlace(); DateTime Actual = DateTime.Now; place.Place_Owner_DNI = data.ClientDNI; place.Place_Owner_Name = data.ClientName; place.idFlight = data.idFlight; place.FP_Date = Actual; db.FlightPlaces.Add(place); try { db.SaveChanges(); } catch (DbUpdateException) { if (FlightPlaceExists(place.numPlace)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = place.numPlace }, place)); }
public async Task <IHttpActionResult> GetFlightPlace(int id) { FlightPlace flightPlace = await db.FlightPlaces.FindAsync(id); if (flightPlace == null) { return(NotFound()); } return(Ok(flightPlace)); }
public async Task <IHttpActionResult> DeleteFlightPlace(int id) { FlightPlace flightPlace = await db.FlightPlaces.FindAsync(id); if (flightPlace == null) { return(NotFound()); } db.FlightPlaces.Remove(flightPlace); await db.SaveChangesAsync(); return(Ok(flightPlace)); }