Exemple #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));
        }
Exemple #2
0
        public async Task <IActionResult> Index()
        {
            //get current user staff id
            var userid  = _globalRepo.GetCurrentUserId();
            var staffId = await _staffRepo.GetStaffIdByUserId(userid);

            //get current user staff details
            var staff = await _staffRepo.GetStaffDetails(staffId);

            var flights  = (await _staffRepo.GetStaffFlights(staffId)).ToList();
            var flights2 = new List <Flight>();

            //below is to get only flights which are at least today or later
            foreach (var f in flights)
            {
                if (f.DepartDateTime.Date >= DateTime.Today)
                {
                    f.OriginLoc1 = await _countryRepo.GetLocById(f.OriginLocID);

                    f.DestLoc1 = await _countryRepo.GetLocById(f.DestLocID);

                    flights2.Add(f);
                }
            }

            //save the selected flights to staff object
            staff.Flights = flights2;

            return(View(staff));
        }
        public async Task <IActionResult> MemberAccountDetails()
        {
            PublicMemberAccDetVM vm = new PublicMemberAccDetVM()
            {
                User = await _globalRepo.GetCurrentUserAsync()
            };

            var bookings           = (await _bookingRepo.GetMemberBookings(vm.User.Id.ToString()));
            var bookingsFlightList = bookings.Select(b => b.GoFlightId).Concat(bookings.Select(b => b.ReturnFlightId));

            vm.LatestFlight = (await _flightRepo.GetAllByFlightId(bookingsFlightList)).Where(t => t.DepartDateTime >= DateTime.Now).OrderBy(f => f.DepartDateTime).FirstOrDefault();
            if (vm.LatestFlight != null)
            {
                vm.LatestFlight.OriginLoc1 = await _countryRepo.GetLocById(vm.LatestFlight.OriginLocID);

                vm.LatestFlight.DestLoc1 = await _countryRepo.GetLocById(vm.LatestFlight.DestLocID);
            }

            return(View(vm));
        }
Exemple #4
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));
        }