/// <summary>
        /// Submit Hotel Info
        /// </summary>
        /// <param name="sodRequestsList"></param>
        /// <param name="sodflightList"></param>
        /// <param name="hotelDetailList"></param>
        /// <returns></returns>
        public JsonResult SubmitHotelInfo(List <TravelRequestMasterModels> sodRequestsList, List <FlightDetailModels> sodflightList, List <TravelRequestHotelDetailModels> hotelDetailList)
        {
            var    s           = 0;
            var    jsonmsg     = string.Empty;
            var    BookingType = string.Empty;
            string hodEmailId  = "";

            sodRequestsList[0].IsVendorBooking = false;
            sodRequestsList[0].IsSJSC          = false;
            //check duplicate hotel data
            if (sodRequestsList[0].IsHotelRequired == true)
            {
                foreach (var i in hotelDetailList)
                {
                    var empcode   = i.EmployeeCode;
                    var checkin   = i.CheckInDate;
                    var hotelcity = i.City;

                    var result = _transportRepository.FindDuplicateDataHotel(empcode, checkin, hotelcity);
                    if (result == true)
                    {
                        jsonmsg             = "Warning: A similar hotel booking already exists. Kindly cancel the previous hotel booking and try again.";
                        TempData["jsonmsg"] = jsonmsg;
                        return(Json(jsonmsg, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            GetLoginUserInfo(sodRequestsList[0].RequestedEmpId.ToString());
            var empInfo = TempData["EmpInfo"] as List <string>;

            hodEmailId = _userRepository.GetHODEmailId(empInfo[8]);
            var r = _userRepository.IsBlanketApproverRole(Convert.ToInt32(empInfo[0]));

            sodRequestsList[0].SJSCHodEmailId = hodEmailId.Split(',')[0].ToString().Trim();
            //Save master Information, flight information, hotel information
            s = _userRepository.SaveOnlyHotelBookingRequest(sodRequestsList, sodflightList, hotelDetailList);
            //send mail to approver and user
            var hotelList = new List <TravelRequestHotelDetailModels>();
            var dicList   = new Dictionary <string, object>();

            dicList = _userRepository.GetSodHotelInfo(Convert.ToInt64(s.ToString()));
            TempData["bookingInfo"] = dicList["bookingInfolist"] as List <TravelRequestMasterModels>;
            TempData["hotelList"]   = dicList["hotelinfolist"] as List <TravelRequestHotelDetailModels>;
            TempData["flightinfo"]  = dicList["flightInfolist"] as List <FlightDetailModels>;
            //Send Email Notification
            if (TempData["hotelList"] != null && TempData["bookingInfo"] != null && TempData["flightinfo"] != null)
            {
                var hotel_List        = TempData["hotelList"] as List <TravelRequestHotelDetailModels>;
                var bookingInfo       = TempData["bookingInfo"] as List <TravelRequestMasterModels>;
                var flightinfo        = TempData["flightinfo"] as List <FlightDetailModels>;
                var emailSubject      = "SOD Only-Hotel Booking Request Notification :" + System.DateTime.Now.ToString();
                var emailTemplateName = "OnlyHotelBookingRequestFor_User.html";
                var emailCredentials  = EmailCredentialsHotel(emailSubject, emailTemplateName, hotel_List, bookingInfo, flightinfo, s.ToString(), "pending");
                TempData["emailData"] = emailCredentials;
                TempData["emailId"]   = bookingInfo[0].EmailId.Trim();
                var emaildata = TempData["emailData"] as EmailNotificationModel;
                var emailid   = TempData["emailId"].ToString();
                EmailNotifications.SendBookingRequestNotificationTo_Requester(emaildata, emailid);

                if (bookingInfo[0].RequestedEmpId.ToString() == hodEmailId.Split(',')[2].ToString().Trim() || r == true)
                {
                    _userRepository.UpdateOnlyHotelApprovalStatus(bookingInfo[0].TravelRequestId);
                    //Redirect to Thank You Page
                    jsonmsg = "SOD Hotel Booking Request ID : " + s.ToString() + " ." + "Booking process has been completed successfully.Your booking request has been sent to Traveldesk for Hotel alignment.";

                    TempData["jsonmsg"] = jsonmsg;
                    return(Json(jsonmsg, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var emailSubject2      = "SOD Hotel Booking Request Notification :" + System.DateTime.Now.ToString();
                    var emailTemplateName2 = "SodHotelBookingRequestFor_HodHotelApproval.html";
                    var emailCredentials2  = EmailCredentialsHotelHod(emailSubject2, emailTemplateName2, hotel_List, bookingInfo, flightinfo, s.ToString(), hodEmailId);

                    var templateData = emailCredentials2.TemplateFilePath;
                    var appLink      = string.Empty;
                    var approvaltype = string.Empty;
                    if (hodEmailId.Length > 0)
                    {
                        var skey = new StringBuilder();
                        skey.Append(bookingInfo[0].TravelRequestId.ToString() + ",");
                        skey.Append(bookingInfo[0].EmailId.Trim() + ",");
                        skey.Append(bookingInfo[0].SodBookingTypeId.ToString() + ",");
                        skey.Append(bookingInfo[0].BookingFor.Trim() + ",");
                        skey.Append(hodEmailId.Split(',')[2].ToString());

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

                        approvaltype = "Please help to accord your Acceptance or Rejection.";
                        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>";

                        templateData = templateData.Replace("[approvaltype]", approvaltype);
                        templateData = templateData.Replace("[appLink]", appLink);
                        templateData = templateData.Replace("[hodName]", hodEmailId.Split(',')[1]);
                        templateData = templateData.Replace("[RequesterName]", bookingInfo[0].RequestedEmpName);
                        emailCredentials2.TemplateFilePath = templateData;
                        //EMail
                        EmailNotifications.SendBookingRequestNotificationTo_Requester(emailCredentials2, hodEmailId.Split(',')[0].ToString().Trim());
                        //SMS Approval
                        SendSMSforApproval(hodEmailId, bookingInfo[0], hotel_List, uri1, uri2);

                        //Redirect to Thank You Page
                        jsonmsg = "SOD Hotel Booking Request ID : " + s.ToString() + " ." + "Booking process has been completed successfully.Your booking request has been sent to your respected approver at  " + hodEmailId.Split(',')[0].ToString();
                    }
                    TempData["jsonmsg"] = jsonmsg;
                    return(Json(jsonmsg, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                jsonmsg             = "Error: Hotel information cannot be saved. Please try again later.";
                TempData["jsonmsg"] = jsonmsg;
                return(Json(jsonmsg, JsonRequestBehavior.AllowGet));
            }
        }
示例#2
0
        ///bulk hotel booking
        public string OnlyhotelBulkBooking(List <OATTravelRequestMasterModal> personalInfo, List <OATTravelRequestPassengerDetailModal> passangerInfo, List <OATTravelRequestFlightDetailModal> flightInfo, List <BulkUploadModels> hotelDetailList)
        {
            var    jsonmsg       = string.Empty;
            var    TrnId         = 0;
            var    bulkMaster    = new BulkUploadMasterModels();
            var    bulkList      = new List <BulkUploadModels>();
            var    empList       = new List <string>();
            var    bulkhotelList = new List <BulkTravelRequestHotelDetailModels>();
            var    time          = System.DateTime.Now.ToString("yyyyMMddHHss");
            string hodEmailId    = "";

            try
            {
                foreach (var i in hotelDetailList)
                {
                    var empcode   = (i.EmpCode.Length == 6) ? ("00" + i.EmpCode) : i.EmpCode;
                    var checkin   = i.CheckInDate;
                    var hotelcity = i.HotelCity;
                    var result    = _transportRepository.FindDuplicateDataHotel(empcode, checkin, hotelcity);
                    if (result == true)
                    {
                        jsonmsg             = "AlreadyExist";
                        TempData["jsonmsg"] = jsonmsg;
                        return(jsonmsg);
                    }
                }

                //Bulk Upload Master
                bulkMaster.FileName    = "OAT View Detail_" + time;
                bulkMaster.FilePath    = "../UploadFile/";
                bulkMaster.CreatedById = Session["EmpCode"].ToString().Trim();
                var UserName = Session["UserInfo"].ToString().Replace("Welcome : ", "").Split('|')[0].ToString();
                bulkMaster.CreatedByName   = UserName;
                bulkMaster.CreatedDate     = DateTime.Now;
                bulkMaster.TransactionDate = DateTime.Now;
                bulkMaster.DepartmentId    = Convert.ToInt32(Session["DeptIdCR"]);
                bulkMaster.VerticalCode    = Session["VerticalId"].ToString();
                bulkMaster.FileStatus      = "Open";
                bulkMaster.BookingType     = "OAT";
                Int32 n = 0;
                //Get HOD Details
                if (personalInfo[0].BookingFor != "Self" && personalInfo[0].BookingFor != "Others (On Behalf of Employee / Non-Employee)")
                {
                    hodEmailId = personalInfo[0].EmailId;
                }
                else
                {
                    hodEmailId = SOD.Services.ADO.SodCommonServices.GetHodEmailDetails(Session["EmpId"].ToString().Trim(), 2);
                }
                foreach (var lst in hotelDetailList)
                {
                    var list = passangerInfo.Where(p => p.EmployeeCode.Contains(lst.EmpCode)).ToList();
                    foreach (var l in list)
                    {
                        lst.SrNo        = n + 1;
                        lst.EmpCode     = (l.EmployeeCode.Length == 6) ? ("00" + l.EmployeeCode):l.EmployeeCode;
                        lst.Title       = l.Gender;
                        lst.FirstName   = l.FirstName;
                        lst.LastName    = l.LastName;
                        lst.Designation = l.Designation;
                        lst.Department  = l.Department;
                        lst.MobileNo    = l.PhoneNo;
                        lst.EmailId     = l.EmailId;
                        lst.CreatedDate = DateTime.Now;
                        lst.PNR         = "";
                        if (personalInfo[0].BookingFor != "Self" && personalInfo[0].BookingFor != "Others (On Behalf of Employee / Non-Employee)")
                        {
                            lst.PNR        = "ERR001";
                            lst.PNR_Status = 1;
                        }
                    }
                    n++;
                }

                if (hodEmailId.Length > 0)
                {
                    bulkMaster.ApproverEmailID = hodEmailId.Split(',')[0].ToString();
                    if (personalInfo[0].TravelRequestId != 0)
                    {
                        hotelDetailList[0].TrnId = personalInfo[0].TravelRequestId;
                        _bulkUploadRepository.saveBulk_newRow(hotelDetailList);
                        TrnId = Convert.ToInt32(personalInfo[0].TravelRequestId);
                    }
                    else
                    {
                        TrnId = _bulkUploadRepository.SaveBulkUploadTemp(bulkMaster, hotelDetailList);
                    }
                }
                else
                {
                    return(TrnId.ToString());
                }
                //Logged User Info
                if (personalInfo[0].BookingFor != "Self" && personalInfo[0].BookingFor != "Others (On Behalf of Employee / Non-Employee)")
                {
                    var approvalList = new List <BulkBookingRequestApprovalModels>();
                    BulkBookingRequestApprovalModels model = new BulkBookingRequestApprovalModels();
                    model.TrRequestId            = TrnId;//Travel Request
                    model.ApprovedByEmpId        = personalInfo[0].RequestedEmpId;
                    model.ApprovalStatus         = 1;
                    model.IsMandatoryTravel      = 0;//Is Mandatory Travel
                    model.ApprovalDate           = System.DateTime.Now;
                    model.Comment                = "SELF APPROVED";
                    model.ApprovedByEmpIdCLevel1 = 0;
                    model.ApprovedByEmpIdCLevel2 = 0;
                    model.ApprovalStatusCLevel1  = 0;
                    model.ApprovalStatusCLevel2  = 0;
                    model.CLevelComment1         = "";
                    model.CLevelComment2         = "";
                    model.CLevelAppDate1         = DateTime.Parse("01/01/1900");
                    model.CLevelAppDate2         = DateTime.Parse("01/01/1900");
                    model.RevenueApprovedStatus  = 0;
                    model.RevenueApprovedDate    = DateTime.Parse("01/01/1900");
                    model.AddNo  = hotelDetailList[0].AddNo;
                    model.BReqId = 0;
                    approvalList.Add(model);
                    var s1 = _bulkUploadRepository.ApproveBulkSodBookingRequestSelective(approvalList);
                    if (s1 == 0)
                    {
                        jsonmsg = "Fail";
                    }
                    else
                    {
                        jsonmsg = TrnId.ToString();
                    }
                }
                else if (hodEmailId.Length > 0)
                {
                    var bulkController = DependencyResolver.Current.GetService <bulkController>();
                    var loggedUserInfo = bulkController.GetLoginUserInfo(Session["EmpId"].ToString().Trim());
                    var hodName        = hodEmailId.Split(',')[1];

                    //var reqName = loggedUserInfo[2] == "M" ? "Mr." : "Ms." + " " + loggedUserInfo[1];
                    //Send Email Notification to  Hod
                    var emailSubject = "OAT Hotel Booking Approval Notification :" + System.DateTime.Now.ToString("dd/MMM/yyyy hh:mm:ss tt");
                    //List<TravelRequestHotelDetailModels> hoteldetails = new List<TravelRequestHotelDetailModels>();
                    List <TravelRequestMasterModels> bookingInfo = new List <TravelRequestMasterModels>();
                    List <FlightDetailModels>        flightinfo  = new List <FlightDetailModels>();
                    var emailTemplateName_hod = "OATRequestNotificationTemplate_HOD.html";
                    var emailCredentials      = EmailCredentialsHotelHod(emailSubject, emailTemplateName_hod, personalInfo, bulkList, TrnId.ToString(), hodName, hotelDetailList, bookingInfo, flightinfo);


                    var skey = new StringBuilder();
                    skey.Append(TrnId.ToString() + ",");
                    skey.Append(hodEmailId.Split(',')[2] + ",");

                    var uri1    = ConfigurationManager.AppSettings["emailBulkApprovalPath"].Trim() + "?str=" + skey + "&type=Ha" + "&edit=" + hotelDetailList[0].AddNo;
                    var uri2    = ConfigurationManager.AppSettings["emailBulkApprovalPath"].Trim() + "?str=" + skey + "&type=Hr" + "&edit=" + hotelDetailList[0].AddNo;
                    var essurl  = ConfigurationManager.AppSettings["essportalUrl"].Trim();
                    var appLink = string.Empty;
                    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>";
                    appLink = appLink + "<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>";

                    var templateData = emailCredentials.TemplateFilePath;
                    //var hodName = hodEmailId.Split(',')[1];

                    templateData = templateData.Replace("[appLink]", appLink);
                    //templateData = templateData.Replace("[hodName]", hodName);
                    emailCredentials.TemplateFilePath = templateData;

                    TempData["emailData_Hod"] = emailCredentials;
                    TempData["emailId_Hod"]   = hodEmailId.Split(',')[0];
                    jsonmsg = TrnId.ToString();
                }
            }
            catch (Exception ex)
            {
                jsonmsg = "Fail";
            }
            return(jsonmsg);
        }