static async Task RunAsync() { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://flyawayairlinewebapi.azurewebsites.net/"); //client.BaseAddress = new Uri("http://localhost:11631/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); for (var i = 0; i < 5000; i++) { var flightBooking = new FlightPlanViewModel { FlightPlanId = i, AircraftName = "Wings " + i, OriginAirport = "Bradley International Airport", DestinationAirport = "Philadelphia International Airpot", DepartureTime = DateTime.Now, ArrivalTime = DateTime.Now.AddHours(5), SeatPrice = 300.50m }; await client.PostAsJsonAsync("api/FlightPlans", flightBooking); Console.WriteLine(String.Format("Transmitted iteration: {0}", i)); } } }
private FlightPlanViewModel MapCommandToViewModelDto(BookFlight command) { var viewModel = new FlightPlanViewModel { FlightPlanId = command.FlightPlanId, AircraftName = command.AircraftName, OriginAirport = command.OriginAirport, DestinationAirport = command.DestinationAirport, DepartureTime = command.DepartureTime, ArrivalTime = command.ArrivalTime, SeatPrice = command.SeatPrice, }; return(viewModel); }
public BookFlight MapViewModelToCommand(FlightPlanViewModel flightPlan) { if (flightPlan == null) { throw new Exception("Flight Plan Cannot Be Null!!!"); } var bookFlightRequest = new BookFlight { FlightPlanId = flightPlan.FlightPlanId, AircraftName = flightPlan.AircraftName, OriginAirport = flightPlan.OriginAirport, DestinationAirport = flightPlan.DestinationAirport, DepartureTime = flightPlan.DepartureTime, ArrivalTime = flightPlan.ArrivalTime, SeatPrice = flightPlan.SeatPrice }; return(bookFlightRequest); }
public HttpResponseMessage Post(FlightPlanViewModel flightPlan) { HttpResponseMessage response; if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } try { _flightPlanService.BookFlight(flightPlan); response = Request.CreateResponse(HttpStatusCode.Created); } catch (Exception e) { response = Request.CreateResponse(HttpStatusCode.BadRequest); } return(response); }
public void BookFlight(FlightPlanViewModel flightPlan) { // Translate and Send to Bus _commandBus.Send(MapViewModelToCommand(flightPlan)); }
public FlightPlanView(FlightPlanViewModel viewmodel) { InitializeComponent(); this.DataContext = viewmodel; }