Exemplo n.º 1
0
        public void SetToBackBusReservationToNewTravelPackage(TravelPackage travelPackage)
        {
            var reservationBusRequest = new BusReservationsToTravelPackageRequest
            {
                TripID    = travelPackage.ToBackBus.TripID,
                SeatCount = travelPackage.ReservationAmount
            };

            BusCompany BusCompany = UnitOfWork.BusCompanyRepository.GetByID(travelPackage.ToBackBus.IdAPI_Bus);

            var consumerBuss = new Consumer <List <BusReservationsToTravelPackageResponse> >();

            List <BusReservationsToTravelPackageResponse> getSeatsResponse = consumerBuss.ReLoadEntities(BusCompany.APIURLToReserveSeatToTravelPackage, "POST", reservationBusRequest).Result;

            foreach (var item in getSeatsResponse)
            {
                var auxSeat = new BusReservedSeat()
                {
                    IdAPI_Bus          = item.TripID,
                    TripID             = item.TripID,
                    Id_BusReservedSeat = item.BookingID,
                    Bus = UnitOfWork.BusRepository.GetByID(item.TripID)
                };
                auxSeat.Bus.BusReservedSeat.Add(auxSeat);
                UnitOfWork.BusReservedSeatRepository.Insert(auxSeat);
                UnitOfWork.BusRepository.Update(auxSeat.Bus);
            }
            UnitOfWork.Save();
        }
Exemplo n.º 2
0
        public void SetToBackBusReservationToNewTravelPackage(TravelPackage travelPackage)
        {
            var reservationBusRequest = new BusReservationsToTravelPackageRequest
            {
                TripID    = travelPackage.ToBackBus.TripID,
                SeatCount = travelPackage.ReservationAmount
            };

            //BusCompany BusCompany = UnitOfWork.BusCompanyRepository.GetByID(travelPackage.ToBackBus.IdAPI_Bus);

            BusCompany BusCompany = new BusCompany
            {
                APIURLToReserveSeatToTravelPackage = "http://demo4736431.mockable.io/ReserverBusSeat",
            };

            var consumerBuss = new Consumer <List <BusReservationsToTravelPackageResponse> >();

            List <BusReservationsToTravelPackageResponse> getSeatsResponse = consumerBuss.ReLoadEntities(BusCompany.APIURLToReserveSeatToTravelPackage, "GET", reservationBusRequest).Result;

            foreach (var item in getSeatsResponse)
            {
                var auxSeat = new BusReservedSeat()
                {
                    TripID          = item.TripID,
                    Id_ReservedSeat = item.BookingID,
                    Bus             = UnitOfWork.BusRepository.GetByID(item.TripID),
                    TravelPackage   = travelPackage,
                    Available       = true
                };
                auxSeat.Bus.BusReservedSeat.Add(auxSeat);
                UnitOfWork.BusRepository.Update(auxSeat.Bus);
            }
            UnitOfWork.Save();
        }