コード例 #1
0
        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));
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void BookFlight(FlightPlanViewModel flightPlan)
 {
     // Translate and Send to Bus
     _commandBus.Send(MapViewModelToCommand(flightPlan));
 }
コード例 #6
0
ファイル: FlightPlanView.xaml.cs プロジェクト: em7/PlgToFp
 public FlightPlanView(FlightPlanViewModel viewmodel)
 {
     InitializeComponent();
     this.DataContext = viewmodel;
 }