public bool EnterTheAirplane(FlightPassenger flightPassenger) { var stringContent = new StringContent(JsonConvert.SerializeObject(flightPassenger), Encoding.UTF8, "application/json"); HttpResponseMessage response = Client.PostAsync("api/values/3", stringContent).Result; if (response.IsSuccessStatusCode) { return(true); } else { return(false); } }
public string BuyTicket(FlightPassenger flightPassenger, Flight flight) { HttpResponseMessage response = Client.GetAsync("buy/" + JsonConvert.SerializeObject(flightPassenger) + "/" + JsonConvert.SerializeObject(flight)).Result; if (response.IsSuccessStatusCode) { HttpContent responseContent = response.Content; var json = responseContent.ReadAsStringAsync().Result; return(json); } else { return(null); } }
public Ticket BuyTicket(FlightPassenger flightPassenger, Flight flight) { var fpFlight = (FlightPassenger : flightPassenger, Flight : flight); var stringContent = new StringContent(JsonConvert.SerializeObject(fpFlight), Encoding.UTF8, "application/json"); HttpResponseMessage response = Client.PostAsync("api/values/3", stringContent).Result; if (response.IsSuccessStatusCode) { HttpContent responseContent = response.Content; var json = responseContent.ReadAsStringAsync().Result; var ticket = JsonConvert.DeserializeObject <Ticket>(json); return(ticket); } else { return(null); } }
public RegistrationServiceAnswer Register(FlightPassenger flightPassenger) { var stringContent = new StringContent(JsonConvert.SerializeObject(flightPassenger), Encoding.UTF8, "application/json"); HttpResponseMessage response = Client.PostAsync("CheckIn/PostPassenger", stringContent).Result; if (response.StatusCode == HttpStatusCode.NoContent) { return(RegistrationServiceAnswer.Registered); } else if (response.StatusCode == HttpStatusCode.NotFound) { return(RegistrationServiceAnswer.TicketNotFound); } else if (response.StatusCode == HttpStatusCode.Forbidden) { return(RegistrationServiceAnswer.BaggageOverweight); } else { return(0); } }