public ActionResult AddPassenger(PassengerDetailsViewModel passengerDetailsViewModel)   //storing passengerdetails to DB
 {
     passengerDetailsViewModel.BookingId = (int)TempData["BookingId"];
     passengerDetailsViewModel.Cost      = ticketBookingBL.CalculateCost(passengerDetailsViewModel.Age, (int)TempData["Cost"]);
     if (ModelState.IsValid)
     {
         PassengerDetails passengerDetails = AutoMapper.Mapper.Map <PassengerDetailsViewModel, PassengerDetails>(passengerDetailsViewModel);
         if (ticketBookingBL.AddPassengerDetails(passengerDetails))
         {
             return(RedirectToAction("DisplayPassengerDetails", "TicketBooking"));
         }
     }
     return(View(passengerDetailsViewModel));
 }
        public ActionResult AddPassenger()          //Adding passenger details
        {
            //TempData["TrainNo"] = trainNo;
            //TempData["ClassName"] = className;
            //TempData["Seats"] = seat;
            List <TicketBooking>             ticketBookingList             = ticketBookingBL.GetBookingId((int)TempData["T_Id"], (int)TempData["C_Id"], (DateTime)TempData["Doj"]); //Get booking list based on train id, DOJ and class id
            List <PassengerDetailsViewModel> passengerDetailsViewModelList = new List <PassengerDetailsViewModel>();

            foreach (TicketBooking booking in ticketBookingList)
            {
                List <PassengerDetails> passengerDetailsList = ticketBookingBL.GetPassengerDetails(booking.BookingId);   //based on previously collected list on ticket booking getting passenger details
                foreach (PassengerDetails passengerDetails in passengerDetailsList)
                {
                    PassengerDetailsViewModel passengerDetailsViewModel = AutoMapper.Mapper.Map <PassengerDetails, PassengerDetailsViewModel>(passengerDetails);
                    passengerDetailsViewModelList.Add(passengerDetailsViewModel);
                }
            }
            ViewBag.Seats = passengerDetailsViewModelList;
            return(View());
            //return View(Tuple.Create<PassengerDetailsViewModel, IEnumerable<PassengerDetailsViewModel>>(new PassengerDetailsViewModel(), passengerDetailsViewModelList));
        }
        public ActionResult DisplayPassengerDetails()
        {
            TicketBooking ticketBooking = ticketBookingBL.GetNoOfPassengers(Convert.ToInt32(TempData["BookingId"]));    // Getting no of passengers from booking table

            TempData["NOP"]   = ticketBooking.NoOfPassengers;
            TempData["Count"] = ticketBookingBL.GetPassengerCountByID(Convert.ToInt32(TempData["BookingId"]));  // Getting count of passengers in passenger table based on current booking ID
            List <PassengerDetails>          passengerList          = ticketBookingBL.GetPassengerDetails(Convert.ToInt32(TempData["BookingId"]));
            List <PassengerDetailsViewModel> passengerViewModelList = new List <PassengerDetailsViewModel>();

            foreach (PassengerDetails details in passengerList)
            {                                                                           //Display passenger Details
                PassengerDetailsViewModel passengerDetailsViewModel = AutoMapper.Mapper.Map <PassengerDetails, PassengerDetailsViewModel>(details);
                passengerViewModelList.Add(passengerDetailsViewModel);
            }
            if ((int)TempData["NOP"] == (int)TempData["Count"])      //Condition to check & get total cost
            {
                int totalMoney = ticketBookingBL.GetTotalCost(Convert.ToInt32(TempData["BookingId"]));
                TempData["TotalCost"] = totalMoney;
            }
            return(View(passengerViewModelList));
        }