Example #1
0
        /// <summary>
        /// Get Booking History details by TrId
        /// </summary>
        /// <param name="trId"></param>
        /// <returns></returns>
        public Dictionary <string, object> GetDetailOfBookingHistoryByTrId(String trId)
        {
            var sodRequestsList    = new List <TravelRequestMasterModels>();
            var sodflightList      = new List <FlightDetailModels>();
            var passengerMealsList = new List <PassengerMealAllocationModels>();

            var dicList = new Dictionary <string, object>();

            dicList            = _sodApproverRepositorty.GetSodBookingInfoForPNR(Convert.ToInt64(trId));
            sodRequestsList    = dicList["bookingInfo"] as List <TravelRequestMasterModels>;
            sodflightList      = dicList["flightInfo"] as List <FlightDetailModels>;
            passengerMealsList = dicList["mealsInfo"] as List <PassengerMealAllocationModels>;

            //Check Meal Option from Old allocation
            if (passengerMealsList.Count == 0)
            {
                //Add Passenger meal Option for SOD Flights
                foreach (var item in sodflightList)
                {
                    var passengerMealsListItem = new PassengerMealAllocationModels();
                    passengerMealsListItem.TravelRequestId = item.TravelRequestId;
                    passengerMealsListItem.Sector          = item.OriginPlace + "-" + item.DestinationPlace;
                    passengerMealsListItem.MealType        = sodRequestsList[0].Meals;
                    passengerMealsListItem.PassengerId     = 0;
                    passengerMealsList.Add(passengerMealsListItem);
                }
            }

            var fcount = 0;

            foreach (var item in sodflightList)
            {
                fcount++;
                var sector = item.OriginPlace + "-" + item.DestinationPlace;
                foreach (var m in passengerMealsList)
                {
                    if (m.Sector == sector && fcount == m.PassengerId)
                    {
                        item.Meals = m.MealType;
                    }
                    if (m.Sector == sector && m.PassengerId == 0)
                    {
                        if (item.Meals != null)
                        {
                            item.Meals = item.Meals + "," + m.MealType;
                        }
                        else
                        {
                            item.Meals = m.MealType;
                        }
                    }
                }
            }
            return(dicList);
        }
        public JsonResult GetBookingInfo()
        {
            var trId = Request.QueryString["trId"].ToString();
            //Display Request wise view details
            var sodRequestsList    = new List <TravelRequestMasterModels>();
            var sodflightList      = new List <FlightDetailModels>();
            var passengerList      = new List <PassengerDetailModels>();
            var passengerMealsList = new List <PassengerMealAllocationModels>();
            var hotelList          = new List <TravelRequestHotelDetailModels>();

            var dicList = new Dictionary <string, object>();

            dicList            = _sodApproverRepositorty.GetSodBookingInfoForPNR(Convert.ToInt64(trId));
            sodRequestsList    = dicList["bookingInfo"] as List <TravelRequestMasterModels>;
            sodflightList      = dicList["flightInfo"] as List <FlightDetailModels>;
            passengerList      = dicList["passInfo"] as List <PassengerDetailModels>;
            passengerMealsList = dicList["mealsInfo"] as List <PassengerMealAllocationModels>;
            hotelList          = dicList["hotelInfo"] as List <TravelRequestHotelDetailModels>;
            //Check Meal Option from Old allocation
            if (passengerMealsList.Count == 0)
            {
                //Add Passenger meal Option for SOD Flights
                foreach (var item in sodflightList)
                {
                    var passengerMealsListItem = new PassengerMealAllocationModels();
                    passengerMealsListItem.TravelRequestId = item.TravelRequestId;
                    passengerMealsListItem.Sector          = item.OriginPlace + "-" + item.DestinationPlace;
                    passengerMealsListItem.MealType        = sodRequestsList[0].Meals;
                    passengerMealsListItem.PassengerId     = 0;

                    passengerMealsList.Add(passengerMealsListItem);
                }
            }

            var fcount = 0;

            foreach (var item in sodflightList)
            {
                fcount++;
                var sector = item.OriginPlace + "-" + item.DestinationPlace;
                foreach (var m in passengerMealsList)
                {
                    if (m.Sector == sector && fcount == m.PassengerId)
                    {
                        item.Meals = m.MealType;
                    }
                    if (m.Sector == sector && m.PassengerId == 0)
                    {
                        if (item.Meals != null)
                        {
                            item.Meals = item.Meals + "," + m.MealType;
                        }
                        else
                        {
                            item.Meals = m.MealType;
                        }
                    }
                }
            }

            return(Json(dicList, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Generate PNR and Send Emal Notification
        /// </summary>
        /// <param name="travelReqId"></param>
        /// <param name="emailId"></param>
        /// <returns></returns>
        private string GeneratePNR(Int64 travelReqId, string emailId)
        {
            //Generate PNR For Approver or HOD
            string strHoldPNR         = ConfigurationManager.AppSettings["strHOLDPNR"].Trim();
            var    sodRequestsList    = new List <TravelRequestMasterModels>();
            var    sodflightList      = new List <FlightDetailModels>();
            var    passengerList      = new List <PassengerDetailModels>();
            var    passengerMealsList = new List <PassengerMealAllocationModels>();
            var    hotelList          = new List <TravelRequestHotelDetailModels>();

            var dicList = new Dictionary <string, object>();

            dicList            = _sodApproverRepositorty.GetSodBookingInfoForPNR(travelReqId);
            sodRequestsList    = dicList["bookingInfo"] as List <TravelRequestMasterModels>;
            sodflightList      = dicList["flightInfo"] as List <FlightDetailModels>;
            passengerList      = dicList["passInfo"] as List <PassengerDetailModels>;
            passengerMealsList = dicList["mealsInfo"] as List <PassengerMealAllocationModels>;
            hotelList          = dicList["hotelInfo"] as List <TravelRequestHotelDetailModels>;

            var reqType = sodRequestsList[0].SodBookingTypeId == 1 ? "SOD" : "NON-SOD";

            //Check Meal Option from Old allocation
            if (passengerMealsList.Count == 0)
            {
                //Add Passenger meal Option for SOD Flights
                foreach (var item in sodflightList)
                {
                    var passengerMealsListItem = new PassengerMealAllocationModels();
                    passengerMealsListItem.TravelRequestId = item.TravelRequestId;
                    passengerMealsListItem.Sector          = item.OriginPlace + "-" + item.DestinationPlace;
                    passengerMealsListItem.MealType        = sodRequestsList[0].Meals;
                    passengerMealsListItem.PassengerId     = 0;
                    passengerMealsList.Add(passengerMealsListItem);
                }
            }
            var pnr = NavitaireServices.Generate_PNR(sodRequestsList, sodflightList, passengerList, passengerMealsList);

            pnr = pnr + "|Close";
            //Update in database
            var c = _sodApproverRepositorty.UpdatePnr(pnr, travelReqId);

            if (c > 0)
            {
                var pnrc = pnr.Split('|')[0];
                if (sodRequestsList[0].IsAmountPaidByTraveller.Equals(true))
                {
                    //Get PNR Booking Time
                    var pnrInfo           = _sodApproverRepositorty.GetPNRAmountAndTime(sodRequestsList[0].TravelRequestId);
                    var holdAmount        = float.Parse(pnrInfo.Split('|')[1]);
                    var holdAmounts       = string.Format("{0:0.00}", holdAmount).ToString();
                    var pnrGenerationTime = Convert.ToDateTime(pnrInfo.Split('|')[2]);

                    //Get Hold Time
                    var holdDateTime = CommonWebMethod.CommonWebMethods.GetHoldBookingDateTime(sodRequestsList[0].SodBookingTypeId, sodRequestsList[0].BookingFor, sodflightList[0].TravelDate, sodflightList[0].DepartureTime, pnrGenerationTime);
                    var HoldTime     = holdDateTime.ToString("t");
                    var HoldDate     = holdDateTime.ToString("dd/MMM/yyyy");
                    var strholdDT    = HoldTime + " dated " + HoldDate;
                    strHoldPNR = strHoldPNR.Replace("[holdDT]", strholdDT);
                    strHoldPNR = strHoldPNR.Replace("[pnrAmt]", holdAmounts);
                    pnrc       = pnrc + "." + strHoldPNR;
                }
                else
                {
                    strHoldPNR = "";
                }

                //Send Email Notification
                var emailSubject           = reqType + " " + "Booking Request Notification Acceptance through Revenue and Itinerary :" + System.DateTime.Now.ToString("dd-MMM-yyyy-hh:mm:ss");
                var emailTemplateName_User = "******";
                var emailCredentials       = EmailCredentials(emailSubject, emailTemplateName_User, sodRequestsList, sodflightList, passengerList, passengerMealsList, hotelList, travelReqId.ToString(), "");
                emailCredentials.TemplateFilePath = emailCredentials.TemplateFilePath.Replace("[PNR]", pnrc);
                EmailNotifications.SendBookingRequestNotificationTo_Requester(emailCredentials, sodRequestsList[0].EmailId.Trim());
            }

            return(pnr.Split('|')[0].Trim().ToString());
        }