示例#1
0
        public void SetToBackFlightReservationToNewTravelPackage(TravelPackage travelPackage)
        {
            var reservationFlightRequest = new FlightReservationsToTravelPackageRequest
            {
                FlightID  = travelPackage.ToBackFlight.Id_Flight,
                SeatCount = travelPackage.ReservationAmount
            };

            FlightCompany FlightCompany = UnitOfWork.FlightCompanyRepository.GetByID(travelPackage.ToBackFlight.Id_Flight);

            var consumerFlights = new Consumer <List <FlightReservationsToTravelPackageResponse> >();

            List <FlightReservationsToTravelPackageResponse> getSeatsResponse = consumerFlights.ReLoadEntities(FlightCompany.APIURLToReserveSeatsToTravelPackage, "POST", reservationFlightRequest).Result;

            foreach (var item in getSeatsResponse)
            {
                var auxSeat = new ReservedSeat()
                {
                    Id_Flight       = item.Id_Flight,
                    Id_ReservedSeat = item.Id_Seat,
                    Flight          = UnitOfWork.FlightRepository.GetByID(item.Id_Flight)
                };
                auxSeat.Flight.ReservedSeat.Add(auxSeat);
                UnitOfWork.ReservedSeatRepository.Insert(auxSeat);
                UnitOfWork.FlightRepository.Update(auxSeat.Flight);
            }
            UnitOfWork.Save();
        }
示例#2
0
        public void SetToBackFlightReservationToNewTravelPackage(TravelPackage travelPackage)
        {
            var reservationFlightRequest = new FlightReservationsToTravelPackageRequest
            {
                FlightID  = travelPackage.ToBackFlight.Id_Flight,
                SeatCount = travelPackage.ReservationAmount
            };

            //FlightCompany FlightCompany = UnitOfWork.FlightCompanyRepository.GetByID(travelPackage.ToGoFlight.Id_Flight);

            FlightCompany FlightCompany = new FlightCompany
            {
                APIURLToReserveSeatsToTravelPackage = "http://demo4736431.mockable.io/ReserveFlightSeat"
            };
            var consumerFlights = new Consumer <List <FlightReservationsToTravelPackageResponse> >();

            List <FlightReservationsToTravelPackageResponse> getSeatsResponse = consumerFlights.ReLoadEntities(FlightCompany.APIURLToReserveSeatsToTravelPackage, "GET", reservationFlightRequest).Result;

            foreach (var item in getSeatsResponse)
            {
                var auxSeat = new FlightReservedSeat()
                {
                    Id_ReservedSeat = item.Id_Seat,
                    Flight          = UnitOfWork.FlightRepository.GetByID(item.Id_Flight),
                    TravelPackage   = travelPackage,
                    Available       = true
                };
                auxSeat.Flight.ReservedSeat.Add(auxSeat);
                UnitOfWork.ReservedSeatRepository.Insert(auxSeat);
                UnitOfWork.FlightRepository.Update(auxSeat.Flight);
            }
            UnitOfWork.Save();
        }