public PutPassengerResponse PutPassenger(PutPassengerRequest request) { var response = new PutPassengerResponse { IsSuccessful = false, Message = "" }; try { _context.Update(request.UpdatePassenger); _context.SaveChanges(); response.IsSuccessful = true; response.Message = "Passenger successfully updated in the database."; } catch (Exception ex) { response.IsSuccessful = false; response.Message = ex.Message; } return(response); }
public IActionResult UpdatePassenger([FromBody] Passenger passenger) { var response = new PutPassengerResponse(); try { response = _passengerService.PutPassenger(new PutPassengerRequest { UpdatePassenger = passenger }); } catch (Exception ex) { return(BadRequest(ex.ToString())); } if (response.IsSuccessful) { return(Ok(response.Message)); } else { return(BadRequest(response.Message)); } }