public HttpResponseMessage Put(int id, [FromBody] TripDTO trip) { Reservation reservation = Reservations.FindBy(r => r.DepartFlightScheduleID == id || r.ReturnFlightScheduleID == id).FirstOrDefault(); if (reservation == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } Trip orignalEntity; FlightDirections flightDirection; if (reservation.DepartFlightScheduleID == id) { orignalEntity = reservation.DepartureFlight; flightDirection = FlightDirections.Departing; } else { orignalEntity = reservation.ReturnFlight; flightDirection = FlightDirections.Returning; } Reservations.UpdateTrip(orignalEntity, trip.FromTripDTO()); Reservations.Save(); // send a reservation update request to the backend booking service UpdateReservationOnBackendSystem(reservation, orignalEntity, flightDirection); return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage Put(int id, [FromBody] TripDTO trip) { Reservation reservation = Reservations.FindBy(r => r.DepartFlightScheduleID == id || r.ReturnFlightScheduleID == id).FirstOrDefault(); if (reservation == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } Trip orignalEntity; if (reservation.DepartFlightScheduleID == id) { orignalEntity = reservation.DepartureFlight; } else { orignalEntity = reservation.ReturnFlight; } Reservations.UpdateTrip(orignalEntity, trip.FromTripDTO()); Reservations.Save(); return(Request.CreateResponse(HttpStatusCode.OK)); }