示例#1
0
        /// <summary>
        /// One way Booking Response
        /// </summary>
        /// <returns></returns>
        public string GetTravelResposefromNavitaire()
        {
            var lst = TempData["SodbookingRequest"] as List <TravelRequestModels>;
            var s   = "";

            switch (lst[0].TravelRequestTypeId)
            {
            case 1:
            case 2:
                s = NavitaireServices.GetAvailability1(lst[0].OriginPlace, lst[0].DestinationPlace, lst[0].TravelDate,
                                                       lst[0].ReturnDate, lst[0].TravelRequestTypeId.ToString(), lst[0].Passengers, lst[0].BookingFor);
                break;

            case 3:
                s = NavitaireServices.GetAvailabilityMulticity(lst);
                break;
            }
            return(s);
        }
        /// <summary>
        /// Reject Sod Booking Request
        /// </summary>
        /// <returns></returns>
        public JsonResult RejectSodBookingRequest(string travelReqId)
        {
            var jsonmsg     = string.Empty;
            var bookingType = string.Empty;
            var strHoldPNR  = string.Empty;

            if ((travelReqId.Split(',')[0] == "undefined") || (travelReqId.Split(',')[0] == ""))
            {
                return(Json("Invalid record.", JsonRequestBehavior.AllowGet));
            }
            var approvalList = new TravelRequestApprovalModels()
            {
                TravelRequestId       = Convert.ToInt64(travelReqId.Split(',')[0]),
                ApprovedByEmpId       = Convert.ToInt32(Session["EmpId"].ToString()),
                RevenueApprovedStatus = 2,//for reject
                RevenueApprovedDate   = System.DateTime.Now,
                Comment = travelReqId.Split(',')[4]
            };
            //Check Duplicate PNR
            var chkpnr = Services.ADO.SodCommonServices.CheckDuplicatePNR(Convert.ToInt64(travelReqId.Split(',')[0]), 1);

            if (!chkpnr.Equals("0"))
            {
                return(Json("Sorry : PNR has been already generated for this Booking Request ID-" + travelReqId.Split(',')[0] + ".Rejection is not allowed.\n Existing PNR No. :" + chkpnr, JsonRequestBehavior.AllowGet));
            }

            //Get Data to show for rejection
            var sodRequestsList    = new List <TravelRequestMasterModels>();
            var sodflightList      = new List <FlightDetailModels>();
            var passengerList      = new List <PassengerDetailModels>();
            var approvalInfoList   = new List <TravelRequestApprovalModels>();
            var passengerMealsList = new List <PassengerMealAllocationModels>();
            var hotelList          = new List <TravelRequestHotelDetailModels>();
            var s = _sodApproverRepositorty.RejectSodBookingRequest_Revenue(approvalList);

            if (s >= 1)
            {
                var dicList = new Dictionary <string, object>();
                dicList            = _sodApproverRepositorty.GetSodBookingInfoForPNR(Convert.ToInt64(travelReqId.Split(',')[0]));
                sodRequestsList    = dicList["bookingInfo"] as List <TravelRequestMasterModels>;
                sodflightList      = dicList["flightInfo"] as List <FlightDetailModels>;
                passengerList      = dicList["passInfo"] as List <PassengerDetailModels>;
                approvalInfoList   = dicList["approvalInfo"] as List <TravelRequestApprovalModels>;
                passengerMealsList = dicList["mealsInfo"] as List <PassengerMealAllocationModels>;
                hotelList          = dicList["hotelInfo"] as List <TravelRequestHotelDetailModels>;
                bookingType        = sodRequestsList[0].SodBookingTypeId == 1 ? "SOD" : "NON-SOD";

                //by lata (to gnerate standby PNR and send Email notification
                if (travelReqId.Split(',')[5] == "1")
                {
                    sodRequestsList[0].BookingFor = "standby";
                    var pnr = NavitaireServices.Generate_PNR(sodRequestsList, sodflightList, passengerList, passengerMealsList);
                    pnr = pnr + "|0001.11";
                    var pnrc = "Your Standby PNR is :" + pnr.Split('|')[0];
                    //insert value in sodtravelrequestmaster_reject with standbyPNR
                    SaveRejectwithStandByPNR(sodRequestsList[0], pnr);

                    sendNotification_RejectStandby(sodRequestsList, sodflightList, passengerList, passengerMealsList, hotelList, travelReqId.Split(',')[0], pnrc);
                }
                //Hold PNR
                if (sodRequestsList[0].IsAmountPaidByTraveller.Equals(true))
                {
                    strHoldPNR = ConfigurationManager.AppSettings["strHOLDPNRPassenger"].Trim();
                }
                else
                {
                    strHoldPNR = "";
                }
                //Send Rejection Email Notification
                var emailSubject      = bookingType + " " + "Booking Request Notification Rejection through Revenue and Itinerary :" + System.DateTime.Now.ToString("dd-MMM-yyyy-hh:mm:ss");
                var emailTemplateName = "SodBookingRequest_Rejection_User.html";
                var emailCredentials  = EmailCredentials(emailSubject, emailTemplateName, sodRequestsList, sodflightList, passengerList, passengerMealsList, hotelList, travelReqId.Split(',')[0].ToString(), strHoldPNR);

                if (approvalInfoList[0].IsMandatoryTravel == 1)
                {
                    emailCredentials.TemplateFilePath = emailCredentials.TemplateFilePath.Replace("[Team]", "Revenue Dept. and forwarded to C-Level Approval.");
                }
                else if (approvalInfoList[0].IsMandatoryTravel == 0)
                {
                    emailCredentials.TemplateFilePath = emailCredentials.TemplateFilePath.Replace("[Team]", "Revenue Dept. and the booking request has been closed.");
                }

                TempData["emailData"] = emailCredentials;
                TempData["emailId"]   = sodRequestsList[0].EmailId.Trim();

                //Check If Mandatory for send email
                if (approvalInfoList[0].IsMandatoryTravel == 1)
                {
                    emailSubject      = bookingType + " " + "Booking Request Notification Rejection through Revenue and Itinerary :" + System.DateTime.Now.ToString("dd-MMM-yyyy-hh:mm:ss");
                    emailTemplateName = "SodBookingRequestNotificationTemplate_HOD.html";

                    //Send Notification to C-Level: Need C- Level Approval Email Template
                    var      counter  = 0;
                    var      emailids = _sodApproverRepositorty.GetCXOMailId(sodRequestsList[0].CLevelApprover1, sodRequestsList[0].CLevelApprover2);
                    string[] arr      = emailids.Split('|');

                    if (arr.Length == 2)
                    {
                        counter = 1;
                    }
                    else if (arr.Length == 4)
                    {
                        counter = 2;
                    }

                    for (int i = 0; i <= counter; i++)
                    {
                        var skey = new StringBuilder();
                        skey.Append(sodRequestsList[0].TravelRequestId.ToString() + ",");
                        skey.Append(sodRequestsList[0].EmailId.Trim() + ",");
                        skey.Append(sodRequestsList[0].SodBookingTypeId.ToString() + ",");
                        skey.Append(sodRequestsList[0].BookingFor.Trim() + ",");
                        skey.Append(arr[i] + ",");
                        skey.Append(sodRequestsList[0].IsMandatoryTravel.ToString() + ",RN");

                        var uri1 = ConfigurationManager.AppSettings["emailApprovalPathcxo"].Trim() + "?str=" + CipherURL.Encrypt(skey + "&type=a");
                        var uri2 = ConfigurationManager.AppSettings["emailApprovalPathcxo"].Trim() + "?str=" + CipherURL.Encrypt(skey + "&type=r");

                        var approvaltype = "Please help to accord your Acceptance or Rejection.";
                        var appLink      = "<table><tr style='font-family:Arial;'><td style='width:110px; height:25px; background-color:#04B431;text-align:center;border-radius:5px'><a name='app' style='color:#fff; text-decoration:none;' href='" + uri1 + "'>Acceptance</a></td> <td>&nbsp;</td> <td style='width:110px; height:25px; background-color:#b33;text-align:center;border-radius:5px'><a name='rej' style='color:#fff; text-decoration:none;' href='" + uri2 + "'>Rejection</a> </td></tr></table>";

                        //Wrap link in template
                        emailCredentials = EmailCredentials(emailSubject, emailTemplateName, sodRequestsList, sodflightList, passengerList, passengerMealsList, hotelList, travelReqId.Split(',')[0].ToString(), strHoldPNR);
                        var templateData = emailCredentials.TemplateFilePath;
                        var hodName      = "Sir/Madam";

                        templateData = templateData.Replace("[approvaltype]", approvaltype);
                        templateData = templateData.Replace("[appLink]", appLink);
                        templateData = templateData.Replace("[hodName]", hodName);
                        emailCredentials.TemplateFilePath = templateData;
                        i = i + 1;
                        EmailNotifications.SendBookingRequestNotificationTo_Requester(emailCredentials, arr[i]);
                    }
                    jsonmsg = bookingType + " " + "booking request has been rejected and has been sent to CXO Panel.";
                }
                else if (approvalInfoList[0].IsMandatoryTravel == 0)
                {
                    //This methos also can be used by Revenue dept to close the Booking Request
                    var trRequestMaster = new TravelRequestMasterModels()
                    {
                        TravelRequestId = Convert.ToInt64(travelReqId.Split(',')[0]),
                        BookingStatus   = "Close",
                        StatusDate      = System.DateTime.Now
                    };
                    var c = _sodApproverRepositorty.CloseSodBookingRequest_HOD(trRequestMaster);
                    jsonmsg = bookingType + " " + "booking request has been rejected and the request has been closed.";
                }
            }
            return(Json(s >= 1 ? jsonmsg : string.Empty, 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());
        }
示例#4
0
        public JsonResult SubmitBookingInfo(List <TravelRequestMasterModels> sodRequestsList, List <FlightDetailModels> sodflightList, List <PassengerDetailModels> passengerList, List <PassengerMealAllocationModels> passengerMealsList, List <TravelRequestCabDetailModels> cabDetailList, List <TravelRequestHotelDetailModels> hotelDetailList)
        {
            var jsonmsg     = string.Empty;
            var BookingType = string.Empty;
            var empInfo     = TempData["EmpInfo"] as List <string>;

            if (empInfo == null)
            {
                return(Json("Error : Please follow again the same process to book the ticket.", JsonRequestBehavior.AllowGet));
            }
            //Update Existing Login Emp Info
            BookingType = "NON-SOD";
            sodRequestsList[0].RequestedEmpName        = empInfo[1];
            sodRequestsList[0].RequestedEmpId          = Convert.ToInt32(empInfo[0]);
            sodRequestsList[0].RequestedEmpCode        = empInfo[9];
            sodRequestsList[0].RequestedEmpDept        = empInfo[2];
            sodRequestsList[0].RequestedEmpDesignation = empInfo[5];
            sodRequestsList[0].RequestDate             = DateTime.Now;
            sodRequestsList[0].BookingStatus           = "Open";
            sodRequestsList[0].StatusDate = DateTime.Parse("01/01/1900");
            sodRequestsList[0].EmailId    = empInfo[3];
            //sodRequestsList[0].Phno = empInfo[4];
            sodRequestsList[0].Title           = empInfo[8] == "M" ? "Mr." : "Ms.";
            sodRequestsList[0].IsOKtoBoard     = CommonWebMethod.OKToBoard.CheckIsOTB(sodRequestsList[0].TravelRequestTypeId, sodflightList);
            sodRequestsList[0].IsVendorBooking = true;
            sodRequestsList[0].IsSJSC          = false;
            //Save booking Information
            var s = _userRepository.SaveBookingRequest(sodRequestsList, sodflightList, passengerList, passengerMealsList, cabDetailList, hotelDetailList);

            if (s >= 1)
            {
                //Check Duplicate PNR
                var chkpnr = Services.ADO.SodCommonServices.CheckDuplicatePNR(Convert.ToInt64(sodRequestsList[0].TravelRequestId), 1);
                if (!chkpnr.Equals("0"))
                {
                    return(Json("Sorry : PNR has already generated for this booking request. Existing PNR No. :" + chkpnr, JsonRequestBehavior.AllowGet));
                }
                //Case 1 :  Confirm Booking
                if (sodRequestsList[0].BookingFor.Trim().ToLower() == "confirm" || sodRequestsList[0].BookingFor.Trim().ToLower() == "standby")
                {
                    //Generate PNR For Blanket Approver Booking
                    var pnr = NavitaireServices.Generate_PNR(sodRequestsList, sodflightList, passengerList, passengerMealsList);
                    if (pnr == "ER001")
                    {
                        pnr = pnr + "|0.00|Error";
                        _userRepository.UpdatePnr(pnr, s);
                        jsonmsg = "PNR generation fail.Error Code :" + pnr.Split('|')[0];
                    }
                    else
                    {
                        pnr = pnr + "|Close";
                        //Update PNR in Database
                        var c = _userRepository.UpdatePnr(pnr, s);
                        if (c > 0)
                        {
                            //Upadte Hotel Approval status
                            if (sodRequestsList[0].IsHotelRequired == true)
                            {
                                _userRepository.UpdateHotelApprovalStatus(sodRequestsList[0].TravelRequestId);
                            }
                            //Redirect to Thank You Page message
                            var pnrc = "Your PNR Number is : " + pnr.Split('|')[0];
                            jsonmsg = BookingType + " " + "Vendor booking process has been completed successfully. Your PNR No. : " + pnr.Split('|')[0];
                            if (sodRequestsList[0].IsAmountPaidByTraveller.Equals(true))
                            {
                                //Get PNR Booking Time
                                var pnrInfo           = _userRepository.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 = 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  && Send Attached Stand By Ticket
                            var emailSubject      = BookingType + " " + "Vendor Booking Request Notification :" + System.DateTime.Now.ToString();
                            var emailTemplateName = "SodBookingRequestNotificationTemplateFor_HOD_Booking.html";
                            var emailCredentials  = EmailCredentials(emailSubject, emailTemplateName, sodRequestsList, sodflightList, passengerList, passengerMealsList, hotelDetailList, s.ToString(), "");
                            emailCredentials.TemplateFilePath = emailCredentials.TemplateFilePath.Replace("[PNR]", pnrc);
                            //Email details for background notifications
                            TempData["emailData"] = emailCredentials;
                            TempData["emailId"]   = sodRequestsList[0].EmailId.Trim();
                            //Redirect to Thank You Page
                            jsonmsg = BookingType + "-" + sodRequestsList[0].TravelRequestId + "  : Vendor Booking process has been completed successfully. Your PNR No. : " + pnr.Split('|')[0];
                            if (sodRequestsList[0].IsAmountPaidByTraveller.Equals(true))
                            {
                                jsonmsg = jsonmsg + ".\n" + ConfigurationManager.AppSettings["strHOLDPNRPassenger"].Trim();
                            }
                        }
                    }
                }
            }
            TempData["jsonmsg"] = jsonmsg;
            return(Json(s >= 1 ? jsonmsg : "Error :Booking Process fail.Please contact to administrator", JsonRequestBehavior.AllowGet));
        }