public ConfirmationModel GetConfirmationData(string sid, string BN) { try { ConfirmationModel confirmationModel = new ConfirmationModel(); HotelBookingDBEntities BookingDB = new HotelBookingDBEntities(); SearchDBEntities searchDB = new SearchDBEntities(); hotelsDBEntities hotelsDB = new hotelsDBEntities(); HotelBedEntity HBDB = new HotelBedEntity(); List <SearchRoomResult> searchRoomResults = new List <SearchRoomResult>(); List <SearchRoomResult> SelectedRooms = new List <SearchRoomResult>(); var BookingData = BookingDB.HotelsBookings.FirstOrDefault(a => a.SessionId == sid && a.Booking_No == BN); var Paxes = BookingDB.HotelBookingPaxs.Where(x => x.Booking_No == BN && x.SID == sid && x.PaxNo == 1); var SearchData = searchDB.SearchCriterias.FirstOrDefault(a => a.sID == sid); var RoomData = searchDB.SearchRoomDatas.Where(a => a.sID == sid).ToList(); var Rooms = Paxes.Select(x => x.RoomRef.ToString()).ToList(); foreach (var item in Rooms) { var roomsearch = searchDB.SearchRoomResults.FirstOrDefault(r => r.sID == sid && r.HotelCode == BookingData.Hotel_ID && r.RoomCode == item); SelectedRooms.Add(roomsearch); } if (BookingData.Provider_ID == "4") { var hotelData = hotelsDB.hotels.FirstOrDefault(a => a.hotelID == BookingData.Hotel_ID); var hotelDesc = hotelsDB.HotelsDescriptions.FirstOrDefault(a => a.hotelID == BookingData.Hotel_ID); confirmationModel.hotel.HotelDescription = hotelDesc.Description1; var hotelsImage = hotelsDB.HotelsImages.Where(a => a.HotelID == BookingData.Hotel_ID).ToList(); confirmationModel.hotel.City = hotelData.cityName; confirmationModel.hotel.Country = hotelData.countryName; confirmationModel.hotel.hotelCode = BookingData.Hotel_ID; confirmationModel.hotel.hotelName = hotelData.hotelName; confirmationModel.hotel.Address = hotelData.address; confirmationModel.hotel.hotelStars = int.Parse(hotelData.rating); if (hotelsImage.Count > 0) { confirmationModel.hotel.hotelThumb = hotelsImage[0].Thum; } confirmationModel.hotel.Location = hotelData.location; } else if (BookingData.Provider_ID == "5") { using (TBOContext tBOContext = new TBOContext()) { var hotelData = tBOContext.HotelDetails.FirstOrDefault(a => a.HotelCode == BookingData.Hotel_ID); var hotelDesc = hotelData.Description; var hotelsImage = tBOContext.HotelImages.Where(a => a.HotelCode == BookingData.Hotel_ID).ToList(); confirmationModel.hotel.City = hotelData.CityName; confirmationModel.hotel.Country = hotelData.CountryName; confirmationModel.hotel.hotelCode = BookingData.Hotel_ID; confirmationModel.hotel.hotelName = hotelData.HotelName; confirmationModel.hotel.Address = hotelData.Address; //confirmationModel.hotel.hotelStars = int.Parse(hotelData.rating); if (hotelsImage.Count > 0) { confirmationModel.hotel.hotelThumb = hotelsImage[0].URL; } confirmationModel.hotel.Location = hotelData.HotelLocation; } } confirmationModel.hotel.CheckIn = SearchData.dateFrom.Value.ToString(); confirmationModel.BookingTime = BookingData.Booking_Time.Value; confirmationModel.hotel.CheckOut = SearchData.dateTo.Value.ToString(); confirmationModel.hotel.Paxes = BookingData.Pax_Qty.Value; confirmationModel.hotel.Rooms = BookingData.Rooms_Qty.Value; var PConfirm = BookingDB.BookingConfirmationDatas.FirstOrDefault(a => a.SessionID == sid && a.BookingNum == BN); if (PConfirm != null) { confirmationModel.ProviderConfirmation = PConfirm.Reference; } confirmationModel.hotel.sellCurrency = BookingData.Sell_Currency; confirmationModel.hotel.TotalSellPrice = BookingData.Sell_Price.Value; confirmationModel.bookingNum = BookingData.Booking_No; confirmationModel.mail = BookingData.Booking_Email; confirmationModel.status = BookingData.Booking_Status; CurrencyRepo repo = new CurrencyRepo(); double ExcahngeRate = repo.GetEveryDayCurrenciesConversion(SearchData.currency, BookingData.Sell_Currency, sid, DateTime.Now).Result.Customer_Sell_Rate; foreach (var item in Paxes) { ConfirmedTraveller traveller = new ConfirmedTraveller(); traveller.FirstName = item.First_name; traveller.LastName = item.Last_Name; traveller.Title = item.Salutations; var roomResult = SelectedRooms.FirstOrDefault(x => x.RoomCode == item.RoomRef.ToString()); searchRoomResults.Add(roomResult); var specRoom1 = SelectedRooms.FirstOrDefault(s => s.RoomCode == item.RoomRef.ToString()); if (specRoom1.Childern != 0) { var specRoom = SelectedRooms.FirstOrDefault(s => s.RoomCode == item.RoomRef.ToString()); var childern = RoomData.Where(a => a.adultNo == specRoom.Adults && a.childernNo == specRoom.Childern).ToList(); if (childern.Count == 1) { var childages = childern[0].childAge.Split('-'); traveller.ChildAge.AddRange(childages.ToList()); } else { var child = RoomData.FirstOrDefault(a => a.adultNo == specRoom.Adults && a.childernNo == specRoom.Childern && a.roomNo == item.RoomRef); var childages = child.childAge.Split('-'); traveller.ChildAge.AddRange(childages.ToList()); } } confirmationModel.travellers.Add(traveller); } foreach (var item in searchRoomResults) { ConfirmedRoom confirmedRoom = new ConfirmedRoom(); if (BookingData.Provider_ID == "5") { var roomNo = int.Parse(item.RoomCode); confirmedRoom.Adult = RoomData.FirstOrDefault(ad => ad.roomNo == roomNo).adultNo ?? default(int); confirmedRoom.Child = RoomData.FirstOrDefault(ad => ad.roomNo == roomNo).childernNo ?? default(int); } else { confirmedRoom.Adult = item.Adults.Value; confirmedRoom.Child = item.Childern.Value; } //var RoomsImage = hotelsImage.Where(a => a.Category.ToLower() == "hotel rooms").ToList(); //*************** //if (RoomsImage.Count > 0) //{ //confirmedRoom.Image = RoomsImage[0].URL; //} confirmedRoom.IsRefundable = item.IsRefundable.Value; confirmedRoom.Paxs = item.PaxSQty.Value; confirmedRoom.RoomCode = item.RoomCode; confirmedRoom.RoomMeal = item.meal; confirmedRoom.RoomType = item.RoomName; confirmedRoom.RateType = item.rateType; List <CancelPolicy> cancelPolicies = new List <CancelPolicy>(); using (HotelBookingDBEntities db = new HotelBookingDBEntities()) { cancelPolicies = db.CancelPolicies.Where(a => a.Sid == sid && a.HotelCode == BookingData.Hotel_ID && a.RoomCode.ToString() == item.RoomCode && a.ProviderID == BookingData.Provider_ID).ToList(); } if (cancelPolicies.Count > 0) { foreach (var p in cancelPolicies) { CancellationRule cancellation = new CancellationRule(); cancellation.FromDate = p.FromDate.ToString(); if (BookingData.Sell_Currency == p.Currency) { cancellation.Price = (double)p.SellPrice.Value; } else { cancellation.Price = (double)p.SellPrice.Value * ExcahngeRate; } cancellation.CanellationRuleText = cancellation.Price + " " + BookingData.Sell_Currency + " From " + p.FromDate.Value.ToString("MMMM dd, yyyy"); confirmedRoom.cancellations.Add(cancellation); } } confirmationModel.rooms.Add(confirmedRoom); } var ConfData = HBDB.BookingConfirmations.FirstOrDefault(a => a.BookingNum == BN); if (ConfData != null) { confirmationModel.PayableNote = "Payable through " + ConfData.supplier + ", acting as agent for the service operating company, details of which can be provided upon request. VAT: " + ConfData.Remark + " Reference:" + ConfData.Reference; } return(confirmationModel); }catch (Exception ex) { LoggingHelper.WriteToFile("ConfirmationController/ERROR/", "ConfirmationDAL" + "INDAL" + sid, "ConfirmData", "Sid is " + sid + " and Booking is" + BN + ex.InnerException?.Message + ex.Message + ex.StackTrace); return(null); } }
public PayLinkRequest GetPayLinkRequestDA(string BN, string Sid, string ip, string pos, string NotTok) { try { PayLinkRequest payLinkData = new PayLinkRequest(); SearchDBEntities searchDB = new SearchDBEntities(); CurrencyRepo currencyManager = new CurrencyRepo(); double totalPrice = 0; HotelBookingDBEntities hotelBookingDB = new HotelBookingDBEntities(); var paxes = hotelBookingDB.HotelBookingPaxs.Where(x => x.Booking_No == BN && x.SID == Sid && x.PaxNo == 1); var Customer = paxes.FirstOrDefault(a => a.Booking_No == BN && a.SID == Sid && a.RoomRef == 1 && a.PaxNo == 1); var BookingData = hotelBookingDB.HotelsBookings.FirstOrDefault(x => x.Booking_No == BN && x.SessionId == Sid); var SearchData = searchDB.SearchCriterias.FirstOrDefault(x => x.sID == Sid); var PaxsRooms = paxes.Select(x => x.Room_No.ToString()).ToList(); var Bookingrooms = searchDB.SearchRoomResults.Where(a => a.sID == Sid && a.HotelCode == BookingData.Hotel_ID && PaxsRooms.Contains(a.RoomCode)).ToList(); if (Customer == null || Bookingrooms.Count == 0 || SearchData == null || BookingData == null) { return(null); } payLinkData.Customer.CustomerEmail = BookingData.Booking_Email; payLinkData.Customer.CustomerPhone = Customer.Phone; payLinkData.Customer.FirstName = Customer.First_name; payLinkData.Customer.LastName = Customer.Last_Name; payLinkData.Customer.IP = ip; payLinkData.Customer.Nationality = SearchData.passengerNationality; payLinkData.Customer.PaymentLocation = pos; payLinkData.Customer.PhoneCodeCountry = Customer.Phone_Code; payLinkData.Customer.PhoneCountryCode = null; payLinkData.BookingInfo.BookingDate = Convert.ToDateTime(string.Format("{0:s}", DateTime.Now)); payLinkData.BookingInfo.CheckInDate = SearchData.dateFrom.Value; payLinkData.BookingInfo.Description = ""; payLinkData.BookingInfo.HGNumber = BN; payLinkData.BookingInfo.Product = "Hotel"; payLinkData.BookingInfo.SearchID = Sid; var url = ConfigurationSettings.AppSettings["SuccessUrl"]; payLinkData.PaymentAuthData.FailUrl = url + "?HG=" + BN + "&sid=" + Sid; payLinkData.PaymentAuthData.SuccessUrl = url + "?HG=" + BN + "&sid=" + Sid; payLinkData.PaymentAuthData.HGToken = null; payLinkData.PaymentAuthData.HGTokenStatus = 0; payLinkData.PaymentAuthData.HGTrackId = null; payLinkData.PaymentAuthData.PaymentMethod = null; payLinkData.PaymentAuthData.PaymentToken = null; var ActionUrlData = ConfigurationSettings.AppSettings["ActionUrl"]; var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; // stop call cHotelCheckAvailability for tbo payLinkData.ActionsUrl.ValidationUrl = ActionUrlData + "/api/HotelCheckAvailability?sid=" + Sid + "&bookingnum=" + BN; payLinkData.ActionsUrl.PostPaymentUrl = ActionUrlData + "/Api/ConfirmHotelStatus?sid=" + Sid + "&bookingNum=" + BN; payLinkData.ActionsUrl.PrePaymentUrl = ""; foreach (var item in Bookingrooms) { totalPrice += item.SellPrice.Value; } double BaseExcahngeRate = currencyManager.GetEveryDayCurrenciesConversion(Bookingrooms[0].SellCurrency, BaseCur, Sid, DateTime.Now).Result.Customer_Sell_Rate; double ExcahngeRate = currencyManager.GetEveryDayCurrenciesConversion(BaseCur, BookingData.Sell_Currency, Sid, DateTime.Now).Result.Customer_Sell_Rate; totalPrice = totalPrice * BaseExcahngeRate; payLinkData.PaymentFareDetails.CustomerPaymentCurrency = BookingData.Sell_Currency; payLinkData.PaymentFareDetails.FareAmount = totalPrice; payLinkData.PaymentFareDetails.TaxAmount = 0; payLinkData.PaymentFareDetails.TotalAmount = totalPrice; payLinkData.PaymentFareDetails.TotalChargeAmount = 0; payLinkData.PaymentFareDetails.ExchangeRate = ExcahngeRate; payLinkData.FormData = null; BookingData.NotificationKey = NotTok; hotelBookingDB.SaveChanges(); return(payLinkData); }catch (Exception ex) { LoggingHelper.WriteToFile("PaymentViewController/ERRor/", "PaymentView" + "INDAL" + Sid, "InComingData", ex.InnerException?.Message + ex.Message + ex.StackTrace); return(null); } }
public AdminBookingDetails GetBookingDetails(string BN) { try { HotelBookingDBEntities BookingDB = new HotelBookingDBEntities(); SearchDBEntities searchDB = new SearchDBEntities(); AdminBookingDetails requiredData = new AdminBookingDetails(); hotelsDBEntities db = new hotelsDBEntities(); CurrencyRepo repo = new CurrencyRepo(); BusinessRulesDBEntities dbp = new BusinessRulesDBEntities(); double CancelRate = 0; var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; var BookinData = BookingDB.HotelsBookings.FirstOrDefault(a => a.Booking_No.ToLower() == BN.ToLower()); var searchData = searchDB.SearchCriterias.FirstOrDefault(a => a.sID == BookinData.SessionId); requiredData.bookingNo = BN; requiredData.bookingPhoneCode = BookinData.Booking_Phone_Code; requiredData.bookingTime = BookinData.Booking_Time.Value; requiredData.CBNumberData.LanguagesList = BookingDB.Languages.ToList(); var lang = requiredData.CBNumberData.LanguagesList.FirstOrDefault(a => a.LanguageCode.ToLower() == searchData.language.ToLower()); if (lang != null) { requiredData.CBNumberData.Language = lang.LanguageID; } requiredData.CBNumberData.PointsOfSaleList = BookingDB.PointsOfSales.ToList(); var pointofsale = requiredData.CBNumberData.PointsOfSaleList.FirstOrDefault(a => a.NameCode.ToLower() == searchData.pos.ToLower()); if (pointofsale != null) { requiredData.CBNumberData.PointOfSale = int.Parse(pointofsale.Code); } requiredData.CBNumberData.SourceList = BookingDB.SourceTraffics.ToList(); var src = requiredData.CBNumberData.SourceList.FirstOrDefault(a => a.Source.ToLower() == searchData.source.ToLower()); if (src != null) { requiredData.CBNumberData.Source = src.Code; } requiredData.checkIN = searchData.dateFrom.Value; requiredData.checkOut = searchData.dateTo.Value; requiredData.city = searchData.cityName; var cityData = db.Cities.FirstOrDefault(c => c.ID.ToString() == searchData.cityName); requiredData.cityName = cityData.City1; var conversionRate = repo.GetEveryDayCurrenciesConversion(BookinData.Sell_Currency, BaseCur, searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; requiredData.costAmount = BookinData.Sell_Price.Value * conversionRate; requiredData.costCurrency = BaseCur; requiredData.country = cityData.countryName; requiredData.customerEmail = BookinData.Booking_Email; var name = BookinData.Pax_Name.Split(' '); requiredData.customerFirstName = name[0]; requiredData.customerID = BookinData.Customer_ID; requiredData.customerLastName = name[1]; requiredData.customerPhone = BookinData.Booking_phone; requiredData.customerPhoneCode = BookinData.Booking_Phone_Code; requiredData.ForeignAmount = BookinData.Sell_Price.Value; //**// requiredData.hotel = BookinData.Hotel_ID; requiredData.hotelConfirmationNo = ""; var hoteldata = db.hotels.FirstOrDefault(a => a.hotelID == BookinData.Hotel_ID); requiredData.hotelName = hoteldata.hotelName; requiredData.lastBookingStatus = BookinData.Booking_Status; requiredData.paxName = BookinData.Pax_Name; requiredData.paxQty = BookinData.Pax_Qty.Value; // get provider var prov = dbp.HotelProviders.FirstOrDefault(a => a.Provider_ID.ToString() == BookinData.Provider_ID); if (prov != null) { requiredData.provider = prov.Provider_Name; } requiredData.roomsQty = BookinData.Rooms_Qty.Value; requiredData.salesChannel = searchData.source; requiredData.sellCurrency = BookinData.Sell_Currency;//*/// var ExchangeRate = repo.GetEveryDayCurrenciesConversion(BaseCur, BookinData.Sell_Currency, searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; requiredData.sellCurrencyExchRate = ExchangeRate; //**///from base to user// requiredData.sellPrice = BookinData.Sell_Price.Value * conversionRate; //**// base curr// var CostData = BookingDB.AvailabilityRes.FirstOrDefault(a => a.BookingNum == BookinData.Booking_No && a.Sid == BookinData.SessionId); requiredData.SupplierCost = CostData.NewTotalcost.Value; /////////////////****************** // requiredData.TotalCostDinars = BookinData.Sell_Price.Value * conversionRate; //**//***with base curr// var dataHotelStautsList = BookingDB.HotelBookingStatus.Where(a => a.Booking_No == BN).ToList(); foreach (var item in dataHotelStautsList) { BookingStatusList bookingStatus = new BookingStatusList(); bookingStatus.Booking_No = BookinData.Booking_No; bookingStatus.Booking_Status = item.Booking_Status; bookingStatus.Status_Time = item.Status_Time.Value; requiredData.BookingStatusList.Add(bookingStatus); } var BookingRooms = BookingDB.HotelBookingRooms.Where(x => x.Booking_No == BookinData.Booking_No && x.SID == BookinData.SessionId).ToList(); for (int i = 0; i < BookingRooms.Count; i++) { BookingRoom bookingRoom = new BookingRoom(); bookingRoom.bookingNo = BookingRooms[i].Booking_No; bookingRoom.meal = BookingRooms[i].Meal; bookingRoom.paxQty = BookingRooms[i].Paxs_Qty.Value; bookingRoom.roomCategory = BookingRooms[i].Room_Category; bookingRoom.roomNo = i + 1;//**// incremented// var roomnum = BookingRooms[i].Room_No.ToString(); var RoomsStats = BookingDB.HotelBookingRoomsStatus.Where(a => a.Booking_No == BN && a.Room_No.ToString() == roomnum).OrderByDescending(a => a.Id).FirstOrDefault(); if (RoomsStats != null) { bookingRoom.RoomStatus = RoomsStats.Room_Status.ToString();//status add culomn// } bookingRoom.roomType = BookingRooms[i].Room_Category; var availabilityHBroom = BookingDB.availabilityRoomRes.Where(x => x.BookingNum == BN && x.roomId.ToString() == roomnum).OrderByDescending(a => a.id).FirstOrDefault(); if (availabilityHBroom != null) { bookingRoom.TotalCostPerRoom = availabilityHBroom.Cost.Value;///********************************* provider cost// } else { var availabilityroom = searchDB.SearchRoomResults.FirstOrDefault(x => x.sID == BookinData.SessionId && x.HotelCode == BookinData.Hotel_ID && x.RoomCode == BookingRooms[i].Room_No.ToString()); if (availabilityroom != null) { bookingRoom.TotalCostPerRoom = availabilityroom.costPrice.Value; } } var roomNum = BookingRooms[i].Room_No.Value; var RoomCancels = BookingDB.CancelPolicies.Where(x => x.RoomCode == roomNum && x.Sid == BookinData.SessionId && x.HotelCode == BookinData.Hotel_ID).ToList(); if (RoomCancels.Count > 0) { CancelRate = repo.GetEveryDayCurrenciesConversion(RoomCancels[0].Currency, BaseCur, searchData.sID, DateTime.Now).Result.Customer_Sell_Rate; } foreach (var item in RoomCancels) { SupplierCancellation supplierCancellation = new SupplierCancellation(); CustomerCancellation cancellation = new CustomerCancellation(); cancellation.Booking_No = BookinData.Booking_No; cancellation.Date_From = item.FromDate.Value; cancellation.Date_To = item.ToDate; cancellation.ID = item.Id; cancellation.No_Show_Amount = (double)Math.Round(item.SellPrice.Value, 3) * CancelRate; cancellation.Room_No = BookingRooms[i].Room_No.Value; cancellation.Rule_Text = cancellation.No_Show_Amount.ToString() + " From " + item.FromDate.Value; supplierCancellation.Booking_No = BookinData.Booking_No; supplierCancellation.Date_From = item.FromDate.Value; supplierCancellation.Date_To = item.ToDate; supplierCancellation.ID = item.Id; supplierCancellation.No_Show_Amount = (double)Math.Round(item.SellPrice.Value, 3) * CancelRate; supplierCancellation.Room_No = BookingRooms[i].Room_No.Value; bookingRoom.SupplierCancellations.Add(supplierCancellation); bookingRoom.CustomerCancellations.Add(cancellation); } var BookingNights = BookingDB.HotelBookingNights.Where(a => a.Booking_No == BookinData.Booking_No && a.Room_No == roomNum).ToList(); foreach (var item in BookingNights) { BookingNight night = new BookingNight(); night.bookingNo = item.Booking_No; night.currency = BaseCur; night.exchangeRate = 1; night.nightDate = item.NightDate.Value; night.rate = item.Rate.Value * conversionRate; night.roomNo = item.Room_No.Value; bookingRoom.bookingNights.Add(night); } var BookingPaxes = BookingDB.HotelBookingPaxs.Where(a => a.SID == BookinData.SessionId && a.Booking_No == BookinData.Booking_No && a.Room_No == roomNum && a.PaxNo == 1).ToList(); foreach (var item in BookingPaxes) { BookingPassenger passenger = new BookingPassenger(); passenger.bookingNo = item.Booking_No; passenger.DateOfBirth = Convert.ToDateTime("0001- 01-01T00:00:00");//********* BD and Just lead(okay) passenger.firstName = item.First_name; passenger.lastName = item.Last_Name; passenger.nationality = searchData.passengerNationality; passenger.paxType = item.Pax_Type; passenger.phone = item.Phone; passenger.phoneCode = item.Phone_Code; passenger.roomNo = item.Room_No.Value; passenger.salutation = item.Salutations; bookingRoom.bookingPassengers.Add(passenger); } var dataRoomStautsList = BookingDB.HotelBookingRoomStatusValues.ToList(); foreach (var item in dataRoomStautsList) { RoomStatusList roomStatus = new RoomStatusList(); roomStatus.ID = item.ID; roomStatus.Status = item.Status; bookingRoom.RoomStatusList.Add(roomStatus); } requiredData.bookingRooms.Add(bookingRoom); } return(requiredData); } catch (Exception ex) { LoggingHelper.WriteToFile("AdminPannelController/ERROR/", "GetBookingDetails" + "INDAL" + BN, "Data", "bookin is " + BN + " and booking is" + BN + ex.Message + ex.StackTrace); return(new AdminBookingDetails()); } }