Ejemplo n.º 1
0
        public async Task <IActionResult> EditFlight(int flightId)
        {
            var countries = await _globalRepo.GetAll <Country>(Country.tableName);

            var flightVM = new AddFlightVM
            {
                Flight    = await _flightRepo.GetByFlightId(flightId),
                Countries = countries.Select(s => new SelectListItem {
                    Value = s.ID.ToString(), Text = s.CountryName, Selected = true
                })
            };

            flightVM.OriginCountryID = _countryRepo.GetLocById(flightVM.Flight.OriginLocID).Result.CountryID;
            flightVM.CitySelectList1 = (await _countryRepo.GetCitiesByCountryId(flightVM.OriginCountryID)).Select(s => new SelectListItem {
                Value = s.ID.ToString(), Text = s.City, Selected = true
            });

            flightVM.DestCountryID   = _countryRepo.GetLocById(flightVM.Flight.DestLocID).Result.CountryID;
            flightVM.CitySelectList2 = (await _countryRepo.GetCitiesByCountryId(flightVM.DestCountryID)).Select(s => new SelectListItem {
                Value = s.ID.ToString(), Text = s.City, Selected = true
            });

            flightVM.DepartDate = flightVM.Flight.DepartDateTime.Date;
            flightVM.DepartTime = flightVM.Flight.DepartDateTime;
            flightVM.ArrDate    = flightVM.Flight.ArrDateTime.Date;
            flightVM.ArrTime    = flightVM.Flight.ArrDateTime;
            return(View(flightVM));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> SelectFlight(string oneIdSelGo, string oneIdSelRet = null)
        {
            var tempBooking = new Booking
            {
                GoFlightId = Convert.ToInt32(oneIdSelGo)
            };

            tempBooking.GoFlight = await _flightRepo.GetByFlightId(tempBooking.GoFlightId);

            tempBooking.GoFlight.OriginLoc1 = await _countryRepo.GetLocById(tempBooking.GoFlight.OriginLocID);

            tempBooking.GoFlight.DestLoc1 = await _countryRepo.GetLocById(tempBooking.GoFlight.DestLocID);

            //if there is return flight, get the flight details
            if (oneIdSelRet != null)
            {
                tempBooking.ReturnFlightId = Convert.ToInt32(oneIdSelRet);
                tempBooking.ReturnFlight   = await _flightRepo.GetByFlightId(tempBooking.ReturnFlightId);

                tempBooking.ReturnFlight.OriginLoc1 = await _countryRepo.GetLocById(tempBooking.ReturnFlight.OriginLocID);

                tempBooking.ReturnFlight.DestLoc1 = await _countryRepo.GetLocById(tempBooking.ReturnFlight.DestLocID);
            }

            //create BookingVM object to create new booking guests property. Booking property is not assigned to facilitate form submission in next action.
            var tempBookingVM = new BookingVM
            {
                BookingNonMembers = new List <BookingNonMember>()
            };

            var adultNum    = HttpContext.Session.GetInt32("adultNum");
            var childrenNum = HttpContext.Session.GetInt32("childrenNum");

            for (byte i = 0; i < adultNum; i++)
            {
                tempBookingVM.BookingNonMembers.Add(new BookingNonMember());
            }
            for (byte i = 0; i < childrenNum; i++)
            {
                tempBookingVM.BookingNonMembers.Add(new BookingNonMember());
            }

            //save tempBooking to session var.
            _globalRepo.SaveObjToSessionJSON <Booking>("tempBookingDetails", tempBooking);

            return(View("FillInBookingDetails", tempBookingVM));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <Flight> > GetFlight(int id)
        {
            var results = await _flightRepo.GetByFlightId(id);

            if (results == null)
            {
                return(NotFound());
            }

            return(results);
        }