public async Task <dynamic> CheckOutVehicle(CheckOutData checkOut) { var vehicle = await _vehicleRepository.Query().Include(v => v.Ticket) .SingleOrDefaultAsync (v => v.Id == checkOut.VehicleId); var lot = await _lotRepository.Query().SingleOrDefaultAsync(l => l.Vehicle == vehicle); if (lot == null) { return(null); } var checkInOutHoursDiff = (checkOut.Checkout - lot.CheckIn).TotalHours; var notPermittedParkHours = checkInOutHoursDiff - vehicle.Ticket.TimeLimit; var exceededTimeLimit = notPermittedParkHours > 0 && vehicle.Ticket.TicketType != TicketType.Vip; if (exceededTimeLimit) { var priceToPay = notPermittedParkHours * vehicle.Ticket.Cost; var result = new { AmountOfParkedHours = checkInOutHoursDiff, priceToPay }; return(result); } await _vehicleRepository.RemoveAsync(vehicle); return(new { AmountOfParkedHours = checkInOutHoursDiff }); }
public static string GetBookingNumberAndManageBooking(CheckOutData data) { try { CurrencyManager currencyManager = new CurrencyManager(); var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, data.Currency, data.Sid); data.SellPrice = Math.Round(data.SellPrice * ExcahngeRate, 3); string BookingNum = null; BookingNum = BookingRepo.checkbookingnumberavailability(data.Sid); if (BookingNum == null) { BookingNum = ""; BookingNum = BookingRepo.GetBookingNumber(data.Sid, data.Src, data.Pid); if (BookingNum != null) { var tasks = new List <Task>(); var tokenSource1 = new CancellationTokenSource(); var tokenSource2 = new CancellationTokenSource(); var token1 = tokenSource1.Token; var token2 = tokenSource2.Token; tasks.Add(Task.Factory.StartNew(() => { data = fillAllTrivellers(data); BookingRepo.SaveBookingResult(data, BookingNum); } , token1)); //tasks.Add(Task.Factory.StartNew(() => //{ // SearchstatisticDA searchstatistic = new SearchstatisticDA(); //searchstatistic.AddMetaSearchStatistic(data, BookingNum); //} // , token2)); //call save Delivary***************** Task.WaitAll(tasks.ToArray()); } return(BookingNum); } else { BookingRepo.EditBookingPaxes(data, BookingNum); return(BookingNum); } } catch (Exception ex) { LoggingHelper.WriteToFile("SaveBookingController/Errors/", "SaveBookingController" + "BLL" + data.Sid, ex.InnerException?.Message, ex.Message + ex.StackTrace); return(null); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.User.Identity.IsAuthenticated) { Response.Redirect("/Account/Login"); } var checkoutdata = Session["CheckOutData"] as CheckOutData; if (checkoutdata == null) { checkoutdata = new CheckOutData(); } var CheckoutItems = Session["Checkout"] as List <Asset>; checkoutdata.CheckOutItems = CheckoutItems; if (!IsPostBack) { if (!Global.Library.Settings.TESTMODE) { //ShippingLabelBtn.Enabled = false; PackingSlipViewBtn.Enabled = false; } but_OK.Enabled = true; Customer = Session["Customer"] as string; Shipper = Session["Shipper"] as string; Engineer = Session["Engineer"] as string; Ordernumber = Session["Ordernumber"] as string; DataBindShipping(Customer, Shipper, Engineer, Ordernumber); var preferShip = Session["PreferedShipMethod"] as string; if (preferShip == null) { ShippingMethodDropDownList.Text = "03-Ground"; //ShippingMethodDropDownList.SelectedIndex = 3; Session["PreferedShipMethod"] = ShippingMethodDropDownList.Text; } else { ShippingMethodDropDownList.Text = preferShip; } decimal TotalWeight = 0; if (CheckoutItems != null) { foreach (var asset in CheckoutItems) { TotalWeight += asset.weight; } PkgWeight.Value = TotalWeight.ToString(); checkoutdata.Package.Weight = TotalWeight.ToString(); } } MessagePlaceHolder.Visible = false; UpdateCheckOutData(checkoutdata); }
public ActionResult CheckoutDetail() { int id = repou.GetUserId(User.Identity.Name); CheckOutData mod = new CheckOutData(); mod = repoc.OrderDetails(id); ViewBag.order_number = mod.order_num; ViewBag.total = mod.totalprice; return(View()); }
public async Task <IActionResult> CheckOutVehicle([FromBody] CheckOutData checkOut) { var result = await _parkingService.CheckOutVehicle(checkOut); if (result != null) { return(Ok(result)); } return(NotFound()); }
public ActionResult CheckoutProduct(string products, string qty) { int s = (int)Session["id"]; if (products != "") { CheckOutData.AddPurchase(products, qty, s); } Session["count"] = null; Session["addlist"] = null; return(RedirectToAction("Index", "Product", new { productId = "" })); }
public string PostAsJson(CheckOutData dataMap, string url) { var client = new HttpClient(); client.DefaultRequestHeaders.Add("apiKey", _apiKey); var result = client.PostAsJsonAsync <CheckOutData>(url, dataMap).Result; result.EnsureSuccessStatusCode(); var stringResult = result.Content.ReadAsStringAsync().Result; return(stringResult); }
public async void AddMetaSearchStatistic(CheckOutData data, string BN) { try { SearchDBEntities searchDB = new SearchDBEntities(); hotelsDBEntities db = new hotelsDBEntities(); SearchStatistic metaData = new SearchStatistic(); var SearchData = searchDB.SearchCriterias.FirstOrDefault(x => x.sID == data.Sid); var hotel = db.hotels.FirstOrDefault(h => h.hotelID == data.HotelID); // var PosData= db. if (hotel != null && SearchData != null) { metaData.BookingNo = BN; metaData.BookingStatus = "New Booking"; metaData.CheckOut = SearchData.dateTo.Value; metaData.ChekIn = SearchData.dateFrom.Value; metaData.CityName = hotel.cityName; metaData.Date = SearchData.sessionCreatedAt.Value; metaData.HotelID = data.HotelID; metaData.HotelName = hotel.hotelName; metaData.POS = SearchData.pos; metaData.ProvideID = data.Pid; metaData.sID = data.Sid; metaData.Source = SearchData.source; } string path = ConfigurationSettings.AppSettings["metaData"]; var client = new HttpClient(); var url = path + "/api/MetaSearchStatistics/POST"; var response = client.PostAsJsonAsync(url, metaData).Result; LoggingHelper.WriteToFile("AddMetaSearchStatistic/", "InSearchstatisticDA ", "ResponseData", response.StatusCode.ToString()); //if (response.IsSuccessStatusCode) //{ //} //else //{ //} }catch (Exception ex) { LoggingHelper.WriteToFile("AddMetaSearchStatistic/Errors/", "InSearchstatisticDA" + data.Sid, ex.Message, ex.Message + ex.StackTrace); } }
public int CheckOut(CheckOutData model) { //Add Database connections string Data String connections = ("Server=;Port=;Database=;User Id=;Password="******"INSERT INTO public.mg_checkoutdata(firstnm, lastnm, address, state, postalcode, mobile, email, shipdate, totalprice, u_id, order_num) VALUES(@firstnm,@lastnm,@address,@state,@postalcode,@mobile,@email,@shipdate,@totalprice, @u_id,@order_num)"; connection.Open(); DateTime date = Convert.ToDateTime(model.shipdate); NpgsqlCommand cmd = new NpgsqlCommand(query, connection); cmd.Parameters.AddWithValue("@firstnm", model.firstnm); cmd.Parameters.AddWithValue("@lastnm", model.lastnm); cmd.Parameters.AddWithValue("@address", model.address); cmd.Parameters.AddWithValue("@state", model.state); cmd.Parameters.AddWithValue("@postalcode", model.postalcode); cmd.Parameters.AddWithValue("@mobile", model.mobile); cmd.Parameters.AddWithValue("@email", model.email); cmd.Parameters.AddWithValue("@shipdate", date); cmd.Parameters.AddWithValue("@totalprice", model.totalprice); cmd.Parameters.AddWithValue("@u_id", model.u_id); //cmd.Parameters.AddWithValue("@cart_id", model.cart_id); cmd.Parameters.AddWithValue("@order_num", model.order_num); int i = 0; try { i = cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { connection.Close(); } return(i); }
public ActionResult Checkout(CheckOutData model) { Random rnd = new Random(); model.order_num = GenerateRandomInt(rnd); model.u_id = repou.GetUserId(User.Identity.Name); model.cart_id = repoc.getCartId(model.u_id); model.totalprice = repo.totalPrise(User.Identity.Name); int i = repoc.CheckOut(model); if (i >= 1) { //repoc.DeleteAllCartItem(model.u_id); return(RedirectToAction("CheckoutDetail")); } else { return(RedirectToAction("Index")); } }
public dynamic initiateMobilePaymentCheckout(string productName_, string phoneNumber_, string currencyCode_, int amount_, string providerChannel_) { var CheckOutData = new CheckOutData() { username = _username, productName = productName_, phoneNumber = phoneNumber_, currencyCode = currencyCode_, amount = amount_, providerChannel = providerChannel_, }; try { string checkOutresponse = PostAsJson(CheckOutData, PAYMENTS_URLString); return(checkOutresponse); } catch (Exception ex) { throw new AfricasTalkingGatewayException(ex); } }
public List <CheckOutData> checkoutbarchart() { ///Add Database connections string Data String connections = ("Server=;Port=;Database=;User Id=;Password="******"select shipdate,order_num,totalprice from mg_checkoutdata"; cmd = new NpgsqlCommand(query, connection); try { NpgsqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { CheckOutData mod = new CheckOutData(); mod.shipdate = dr["shipdate"].ToString(); // model.order_num = Convert.ToInt32(dr["order_num"]); mod.totalprice = Convert.ToInt32(dr["totalprice"]); model.Add(mod); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { connection.Close(); } return(model); }
public CheckOutData OrderDetails(int u_id) { //Add Database connections string Data String connections = ("Server=;Port=;Database=;User Id=;Password="******"SELECT order_num,totalprice FROM public.mg_checkoutdata WHERE u_id=@u_id"; connection.Open(); NpgsqlCommand cmd = new NpgsqlCommand(query, connection); cmd.Parameters.AddWithValue("@u_id", u_id); CheckOutData model = new CheckOutData(); try { NpgsqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { model.order_num = Convert.ToInt32(dr["order_num"]); model.totalprice = Convert.ToInt32(dr["totalprice"]); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { connection.Close(); } return(model); }
// POST: api/HotelBooking public IHttpActionResult Post([FromBody] CheckOutData value) { LoggingHelper.WriteToFile("SaveBookingController/Request/", "SaveController" + "INController" + value.Sid, "RequestObject", JsonConvert.SerializeObject(value)); try { if (ModelState.IsValid) { var BookingNum = BookingManager.GetBookingNumberAndManageBooking(value); if (BookingNum != null) { // var myAnonymousType = new { bookingNum= BookingNum}; return(Ok(new { bookingNum = BookingNum })); } return(Ok("Booking Number not Created")); } return(BadRequest(ModelState)); }catch (Exception ex) { LoggingHelper.WriteToFile("SaveBookingController/Errors/", "SaveController" + "INController" + value.Sid, ex.InnerException?.Message, ex.Message + ex.StackTrace); return(BadRequest(ex.Message)); } }
public static void SaveBookingResult(CheckOutData BookingResults, string BNNum) { List <int> rooms = new List <int>(); try { var BaseCur = ConfigurationSettings.AppSettings["BaseCur"]; foreach (var item in BookingResults.Travellers) { if (!rooms.Contains(item.roomNo)) { rooms.Add(item.roomNo); } } using (DBConnection db = new DBConnection()) { db.DB_OpenConnection("HB"); SearchDBEntities searchDB = new SearchDBEntities(); #region old code save use SP // hotel rates //DataTable dt = new DataTable(); //DataColumn SessionId = new DataColumn("SessionId"); //DataColumn Booking_No = new DataColumn("Booking_No"); //DataColumn City = new DataColumn("City"); //DataColumn HotelId = new DataColumn("HotelId"); //DataColumn HotelPId = new DataColumn("HotelPId"); //DataColumn Rooms_Qty = new DataColumn("Rooms_Qty"); //DataColumn Pax_Qty = new DataColumn("Pax_Qty"); //DataColumn Booking_Status = new DataColumn("Booking_Status"); //DataColumn Customer_ID = new DataColumn("Customer_ID"); //DataColumn Provider_ID = new DataColumn("Provider_ID"); //DataColumn Sell_Price = new DataColumn("Sell_Price"); //DataColumn Sell_Currency = new DataColumn("Sell_Currency"); //DataColumn Booking_Phone_Code = new DataColumn("Booking_Phone_Code"); //DataColumn Booking_Phone = new DataColumn("Booking_Phone"); //DataColumn Booking_Email = new DataColumn("Booking_Email"); //DataColumn Pax_Name = new DataColumn("Pax_Name"); //DataColumn Foreign_Amount = new DataColumn("Foreign_Amount"); //DataColumn Total_Cost_main = new DataColumn("Total_Cost_main"); //DataColumn Bookingsrc = new DataColumn("src"); //Rooms_Qty.DataType = typeof(int); //Pax_Qty.DataType = typeof(int); //Sell_Price.DataType = typeof(double); //Foreign_Amount.DataType = typeof(double); //Total_Cost_main.DataType = typeof(int); //dt.Columns.Add(SessionId); //dt.Columns.Add(Booking_No); //dt.Columns.Add(City); //dt.Columns.Add(HotelId); //dt.Columns.Add(HotelPId); //dt.Columns.Add(Rooms_Qty); //dt.Columns.Add(Pax_Qty); //dt.Columns.Add(Booking_Status); //dt.Columns.Add(Customer_ID); //dt.Columns.Add(Provider_ID); //dt.Columns.Add(Sell_Price); //dt.Columns.Add(Sell_Currency); //dt.Columns.Add(Booking_Phone_Code); //dt.Columns.Add(Booking_Phone); //dt.Columns.Add(Booking_Email); //dt.Columns.Add(Pax_Name); //dt.Columns.Add(Foreign_Amount); //dt.Columns.Add(Total_Cost_main); //dt.Columns.Add(Bookingsrc); //// room result //DataTable dr = new DataTable(); //DataColumn rsID = new DataColumn("sID"); //DataColumn rProviderID = new DataColumn("ProviderId"); //DataColumn rBooking_No = new DataColumn("Booking_No"); //DataColumn rRoomNo = new DataColumn("RoomNo"); //DataColumn rRoomCat = new DataColumn("RoomCat"); //DataColumn rRoomType = new DataColumn("RoomType"); //DataColumn rMeal = new DataColumn("Meal"); //DataColumn rPaxesQty = new DataColumn("PaxesQty"); //DataColumn rRefund = new DataColumn("Refund"); //rProviderID.DataType = typeof(int); //rRoomNo.DataType = typeof(int); //rPaxesQty.DataType = typeof(int); //dr.Columns.Add(rsID); //dr.Columns.Add(rProviderID); //dr.Columns.Add(rBooking_No); //dr.Columns.Add(rRoomNo); //dr.Columns.Add(rRoomCat); //dr.Columns.Add(rRoomType); //dr.Columns.Add(rMeal); //dr.Columns.Add(rPaxesQty); //dr.Columns.Add(rRefund); //DataTable dn = new DataTable(); //DataColumn nBooking_No = new DataColumn("Booking_No"); //DataColumn nNdate = new DataColumn("Ndate"); //DataColumn nrate = new DataColumn("rate"); //DataColumn nCurrency = new DataColumn("Currency"); //DataColumn nRoomNo = new DataColumn("Room_No"); //DataColumn nExchangeRate = new DataColumn("ExchangeRate"); //nNdate.DataType = typeof(DateTime); //nrate.DataType = typeof(double); //nRoomNo.DataType = typeof(int); //nExchangeRate.DataType = typeof(double); //dn.Columns.Add(nBooking_No); //dn.Columns.Add(nNdate); //dn.Columns.Add(nrate); //dn.Columns.Add(nCurrency); //dn.Columns.Add(nRoomNo); //dn.Columns.Add(nExchangeRate); //DataTable dp = new DataTable(); //DataColumn pBooking_No = new DataColumn("Booking_No"); //DataColumn psID = new DataColumn("sID"); //DataColumn pRoomNo = new DataColumn("RoomNo"); //DataColumn ppaxtype = new DataColumn("paxtype"); //DataColumn pFirstName = new DataColumn("FirstName"); //DataColumn pLastName = new DataColumn("LastName"); //DataColumn saluation = new DataColumn("saluation"); //DataColumn pBD = new DataColumn("BD"); //DataColumn pNationality = new DataColumn("Nationality"); //DataColumn pphone = new DataColumn("phone"); //DataColumn pphoneCode = new DataColumn("phoneCode"); //DataColumn PPaxNo = new DataColumn("PaxNo"); //DataColumn PRoomRef = new DataColumn("Ref"); //pRoomNo.DataType = typeof(int); //PPaxNo.DataType = typeof(int); //PRoomRef.DataType = typeof(int); //dp.Columns.Add(psID); //dp.Columns.Add(pBooking_No); //dp.Columns.Add(pRoomNo); //dp.Columns.Add(ppaxtype); //dp.Columns.Add(pFirstName); //dp.Columns.Add(pLastName); //dp.Columns.Add(saluation); //dp.Columns.Add(pBD); //dp.Columns.Add(pNationality); //dp.Columns.Add(pphone); //dp.Columns.Add(pphoneCode); //dp.Columns.Add(PPaxNo); //dp.Columns.Add(PRoomRef); //DataRow DtHr = dt.NewRow(); //DtHr["SessionId"] = BookingResults.Sid; //DtHr["Booking_No"] = BNNum;//////////********************* //DtHr["City"] = BookingResults.CityName; //DtHr["HotelId"] = BookingResults.HotelID; //DtHr["HotelPId"] = BookingResults.ProviderHotelID; //DtHr["Rooms_Qty"] = int.Parse(BookingResults.RoomQty); //DtHr["Pax_Qty"] = BookingResults.Travellers.Count; //DtHr["Booking_Status"] = "NewBooking"; #endregion HotelBookingDBEntities hotelBookingDB = new HotelBookingDBEntities(); var traveller = BookingResults.Travellers.FirstOrDefault(a => a.Main == true); var customer = hotelBookingDB.Customers.FirstOrDefault(a => a.Email == BookingResults.Mail); var CusID = 0; if (customer != null) { //DtHr["Customer_ID"] = customer.ID; CusID = customer.ID; } else { Customer cus = new Customer(); cus.Country = traveller.nationality; cus.Date_Of_Birth = traveller.DateOfBirth; cus.Email = BookingResults.Mail; cus.First_Name = traveller.firstName; cus.Last_Name = traveller.lastName; cus.Phone = traveller.phone; cus.Phone_Code = traveller.phoneCode; cus.Salutations = traveller.salutation; hotelBookingDB.Customers.Add(cus); hotelBookingDB.SaveChanges(); //DtHr["Customer_ID"] = cus.ID; CusID = cus.ID; } //DtHr["Provider_ID"] = BookingResults.Pid; //DtHr["Sell_Price"] = BookingResults.SellPrice; //DtHr["Sell_Currency"] = BookingResults.Currency; //DtHr["Booking_Phone_Code"] = traveller.phoneCode; //DtHr["Booking_Phone"] = traveller.phone; //DtHr["Booking_Email"] = BookingResults.Mail; traveller.lastName = traveller.lastName.Replace(" ", String.Empty); //DtHr["Pax_Name"] = traveller.firstName + " " + traveller.lastName; //DtHr["Foreign_Amount"] = BookingResults.totalCost; //DtHr["Total_Cost_main"] = BookingResults.totalCost; //DtHr["src"] = BookingResults.Src; //TBO HotelsBooking hotelsBooking = new HotelsBooking { //Booking_Conf = Booking_Email = BookingResults.Mail, Booking_No = BNNum, Booking_phone = traveller.phone, Booking_Phone_Code = traveller.phoneCode, Booking_Status = "NewBooking", Booking_Time = DateTime.UtcNow, City = BookingResults.CityName, Customer_ID = CusID.ToString(), Foreign_Amount = BookingResults.totalCost, //Form_Of_Payment //HotelConfirmationNo HotelProviderID = BookingResults.ProviderHotelID, Hotel_ID = BookingResults.HotelID, //InvoicePdf //NotificationKey Pax_Name = traveller.firstName + " " + traveller.lastName, Pax_Qty = BookingResults.Travellers.Count, //PromoCode_Amount Provider_ID = BookingResults.Pid, Rooms_Qty = int.Parse(BookingResults.RoomQty), Sell_Currency = BookingResults.Currency, Sell_Price = BookingResults.SellPrice, Total_Cost_Main_Currency = BookingResults.totalCost, SessionId = BookingResults.Sid, Sales_Channel = BookingResults.Src }; hotelBookingDB.HotelsBookings.Add(hotelsBooking); // //dt.Rows.Add(DtHr); var searchData = searchDB.SearchCriterias.FirstOrDefault(a => a.sID == BookingResults.Sid); int duration = Convert.ToInt32((searchData.dateTo - searchData.dateFrom).Value.TotalDays); var roomsDB = searchDB.SearchRoomResults.Where(a => a.sID == BookingResults.Sid && a.HotelCode == BookingResults.HotelID); var Bookingrooms = BookingResults.Travellers.Select(x => x.roomRef).ToList().Distinct(); foreach (var item in Bookingrooms) { var specificRoom = BookingResults.Travellers.FirstOrDefault(x => x.roomRef == item); var roomdata = roomsDB.FirstOrDefault(a => a.RoomCode == specificRoom.roomNo.ToString() && a.HotelCode == BookingResults.HotelID); HotelBookingRoom room = new HotelBookingRoom { Booking_No = BNNum, Meal = roomdata.meal, Paxs_Qty = roomdata.PaxSQty, PID = int.Parse(BookingResults.Pid), //Room_Category = roomdata.RoomName, Room_No = specificRoom.roomNo, //Room_Type = roomdata.roomType, SID = BookingResults.Sid, }; hotelBookingDB.HotelBookingRooms.Add(room); //DataRow DRR = dr.NewRow(); //DRR["sID"] = BookingResults.Sid; //DRR["ProviderId"] = int.Parse(BookingResults.Pid);////////// //DRR["Booking_No"] = BNNum;////////////////////////////************* //DRR["RoomNo"] = specificRoom.roomNo; //DRR["RoomCat"] = roomdata.RoomName; //DRR["RoomType"] = roomdata.roomType; //DRR["Meal"] = roomdata.meal; //DRR["PaxesQty"] = roomdata.PaxSQty; //// DRR["Refund"] = "";////////////// //dr.Rows.Add(DRR); for (int j = 0; j < duration; j++) { HotelBookingNight night = new HotelBookingNight { Booking_No = BNNum, Currency = roomdata.SellCurrency, NightDate = searchData.dateFrom.Value.AddDays(j + 1), Rate = roomdata.SellPrice.Value / duration, Room_No = specificRoom.roomNo }; hotelBookingDB.HotelBookingNights.Add(night); //DataRow DrN = dn.NewRow(); //DrN["Booking_No"] = BNNum;//*************************** //DrN["Ndate"] = searchData.dateFrom.Value.AddDays(j + 1); //DrN["rate"] = roomdata.SellPrice.Value / duration; //DrN["Currency"] = roomdata.SellCurrency; //DrN["Room_No"] = specificRoom.roomNo; //dn.Rows.Add(DrN); } HotelBookingRoomsStatu roomsStatus = new HotelBookingRoomsStatu(); roomsStatus.Booking_No = BNNum; roomsStatus.Room_No = specificRoom.roomNo; roomsStatus.Room_Status = 1; hotelBookingDB.HotelBookingRoomsStatus.Add(roomsStatus); } foreach (var item in BookingResults.Travellers) { HotelBookingPax pax = new HotelBookingPax { Booking_No = BNNum, DateOfBirth = item.DateOfBirth.ToString(), First_name = item.firstName, Last_Name = item.lastName, Nationality = item.nationality, PaxNo = item.TravellerId, Pax_Type = item.paxType, Phone = item.phone, Phone_Code = item.phoneCode, RoomRef = item.roomRef, Room_No = item.roomNo, //room index Salutations = item.salutation, SID = BookingResults.Sid, Lead = item.Main }; hotelBookingDB.HotelBookingPaxs.Add(pax); //DataRow Dpri = dp.NewRow(); //Dpri["sID"] = BookingResults.Sid; //Dpri["Booking_No"] = BNNum;//////////**************** //Dpri["RoomNo"] = item.roomNo;//////////////////////////// //Dpri["paxtype"] = item.paxType; //Dpri["FirstName"] = item.firstName; //Dpri["LastName"] = item.lastName; //Dpri["saluation"] = item.salutation; //Dpri["BD"] = item.DateOfBirth.ToString(); //Dpri["Nationality"] = item.nationality; //Dpri["phone"] = item.phone; //Dpri["phoneCode"] = item.phoneCode; //Dpri["PaxNo"] = item.TravellerId; //Dpri["Ref"] = item.roomRef; //dp.Rows.Add(Dpri); } HotelBookingStatu bookingStatus = new HotelBookingStatu(); bookingStatus.Booking_No = BNNum; bookingStatus.Booking_Status = "New Booking"; bookingStatus.Status_Time = DateTime.Now; hotelBookingDB.HotelBookingStatus.Add(bookingStatus); //Dictionary<string, object> keyValues = new Dictionary<string, object>(); //keyValues.Add("Bookindata", dt); //keyValues.Add("RoomList", dr); //keyValues.Add("nigtData", dn); //keyValues.Add("paxes", dp); // db.SaveSP_Async("SaveBookingResult", keyValues); hotelBookingDB.SaveChanges(); } } catch (Exception ex) { LoggingHelper.WriteToFile("SaveBookingController/Errors/", "SaveSearchResult_" + BookingResults.Sid, "", ex.Message + " Sourse :" + ex.Source + " Stack Trace :" + ex.StackTrace); throw ex; } }
static CheckOutData fillAllTrivellers(CheckOutData data) { try { if (data.Pid == "5") { //foreach (var item in data.Travellers) //{ // item.Main = true; //} // CheckOutData outData = new CheckOutData(); string[] demydata = new string[] { "dy", "di", "sy", "hm", "lm" }; string[] demydataCh = new string[] { "dyc", "dci", "syc", "hmc" }; int numOfRooms = data.Travellers.Count; List <BookingTraveller> LeadTraveller = new List <BookingTraveller>(); LeadTraveller.AddRange(data.Travellers); SearchDBEntities searchDB = new SearchDBEntities(); var CountPax = searchDB.ProviderSessions.Where(ss => ss.SearchId == data.Sid).ToList(); var Rooms = GetRooms.GetRoomsForTraveller(data.Sid, data.HotelID, data.Pid, data.Travellers.Select(a => a.roomNo.ToString()).ToList()); for (int i = 0; i < CountPax.Count; i++) { //foreach (var item in CountPax) //{ data.Travellers[i].roomRef = i + 1; var room = Rooms.FirstOrDefault(a => a.RoomCode == LeadTraveller[i].roomNo.ToString()); if (CountPax[i].Adult > 1) { for (int j = 0; j < CountPax[i].Adult - 1; j++) { BookingTraveller traveller = new BookingTraveller(); traveller.firstName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).firstName + demydata[j]; traveller.lastName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).lastName; traveller.Main = false; traveller.paxType = "adult"; traveller.roomNo = int.Parse(room.RoomCode); traveller.salutation = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).salutation; traveller.TravellerId = j + 2; traveller.roomRef = i + 1; data.Travellers.Add(traveller); } } if (CountPax[i].Child > 0) { for (int c = 0; c < CountPax[i].Child; c++) { BookingTraveller traveller = new BookingTraveller(); traveller.firstName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).firstName + demydataCh[c]; traveller.lastName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).lastName; traveller.Main = false; traveller.paxType = "Child"; traveller.roomNo = int.Parse(room.RoomCode); traveller.salutation = "mr"; traveller.TravellerId = c + room.Adults.Value + 2; traveller.roomRef = i + 1; data.Travellers.Add(traveller); } } //} } } else { // CheckOutData outData = new CheckOutData(); string[] demydata = new string[] { "dy", "di", "sy", "hm", "lm" }; string[] demydataCh = new string[] { "dyc", "dci", "syc", "hmc" }; int numOfRooms = data.Travellers.Count; List <BookingTraveller> LeadTraveller = new List <BookingTraveller>(); LeadTraveller.AddRange(data.Travellers); var Rooms = GetRooms.GetRoomsForTraveller(data.Sid, data.HotelID, data.Pid, data.Travellers.Select(a => a.roomNo.ToString()).ToList()); for (int i = 0; i < numOfRooms; i++) { data.Travellers[i].roomRef = i + 1; var room = Rooms.FirstOrDefault(a => a.RoomCode == LeadTraveller[i].roomNo.ToString()); if (room.Adults > 1) { for (int j = 0; j < room.Adults - 1; j++) { BookingTraveller traveller = new BookingTraveller(); traveller.firstName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).firstName + demydata[j]; traveller.lastName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).lastName; traveller.Main = false; traveller.paxType = "adult"; traveller.roomNo = int.Parse(room.RoomCode); traveller.salutation = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).salutation; traveller.TravellerId = j + 2; traveller.roomRef = i + 1; data.Travellers.Add(traveller); } } if (room.Childern > 0) { for (int c = 0; c < room.Childern; c++) { BookingTraveller traveller = new BookingTraveller(); traveller.firstName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).firstName + demydataCh[c]; traveller.lastName = data.Travellers.FirstOrDefault(x => x.roomNo.ToString() == room.RoomCode).lastName; traveller.Main = false; traveller.paxType = "Child"; traveller.roomNo = int.Parse(room.RoomCode); traveller.salutation = "mr"; traveller.TravellerId = c + room.Adults.Value + 1; traveller.roomRef = i + 1; data.Travellers.Add(traveller); } } } } return(data); } catch (Exception ex) { throw ex; } }
public void SaveBookingDetails(CheckOutData data) { throw new NotImplementedException(); }
private CheckOutData UpdateCheckOutData(CheckOutData checkoutdata) { //Code checkoutdata.Code = checkoutdata.ParseUpsCodeString(Session["PreferedShipMethod"] as string); if (checkoutdata.Package.Weight == null) { checkoutdata.Package.Weight = "1"; PkgWeight.Value = "1"; } //pkg decimal TotalWeight = 0; var CheckoutItems = Session["Checkout"] as List <Asset>; if (CheckoutItems != null) { } //package string userinputweight = PkgWeight.Value; try { TotalWeight = Convert.ToDecimal(userinputweight); if (TotalWeight == 0) { TotalWeight = 1; PkgWeight.Value = "1"; } } catch { } try { checkoutdata.Package.Weight = TotalWeight.ToString(); checkoutdata.Package.H = Convert.ToInt32(string.IsNullOrEmpty(PkgHeight.Value) ? "0" : PkgHeight.Value); checkoutdata.Package.L = Convert.ToInt32(string.IsNullOrEmpty(PkgLength.Value) ? "0" : PkgHeight.Value); checkoutdata.Package.W = Convert.ToInt32(string.IsNullOrEmpty(PkgWidth.Value) ? "0" : PkgHeight.Value); checkoutdata.Package.PackType = UPS_PackagingType.CustomerSupplied; checkoutdata.Package.reference = PkgReference.Value; checkoutdata.Package.reference2 = PkgReference2.Value; } catch { } //From checkoutdata.From.AddressLine = new string[] { SprAddr.Value, SprAddr2.Value }; checkoutdata.From.Name = SprCompany.Value; checkoutdata.From.AttentionName = SprName.Value; checkoutdata.From.City = SprCty.Value; checkoutdata.From.State = SprState.Value; checkoutdata.From.Postal = SprPostal.Value; checkoutdata.From.Country = SprCountry.Value; checkoutdata.From.Phone = "18595345201"; //To checkoutdata.To.AddressLine = new string[] { ToAddr.Value, ToAddr2.Value }; checkoutdata.To.Name = ToCompany.Value; checkoutdata.To.AttentionName = ToName.Value; checkoutdata.To.City = ToCty.Value; checkoutdata.To.State = ToState.Value; checkoutdata.To.Postal = ToPostal.Value; checkoutdata.To.Country = ToCountry.Value; checkoutdata.To.Phone = "18595345201"; checkoutdata.Shipper = checkoutdata.From; //save Session["CheckOutData"] = checkoutdata; return(checkoutdata); }
public static int EditBookingPaxes(CheckOutData checkOutData, string BN) { try { int EffectedRows = 0; int indx = 1; HotelBookingDBEntities dBEntitiy = new HotelBookingDBEntities(); for (int i = 0; i < checkOutData.Travellers.Count; i++) { checkOutData.Travellers[i].roomRef = i + 1; } var booking = dBEntitiy.HotelBookingPaxs.Where(a => a.SID == checkOutData.Sid && a.Booking_No == BN && a.PaxNo == 1); if (booking != null) { foreach (var item in booking) { var pax = checkOutData.Travellers.FirstOrDefault(x => x.roomNo == item.Room_No && x.roomRef == indx && x.TravellerId == item.PaxNo); if (pax != null) { item.DateOfBirth = pax.DateOfBirth.ToString(); item.First_name = pax.firstName; item.Last_Name = pax.lastName; item.Nationality = pax.nationality; item.Pax_Type = pax.paxType; item.Phone = pax.phone; item.Phone_Code = pax.phoneCode; item.Salutations = pax.salutation; } indx = indx + 1; } var BookingData = dBEntitiy.HotelsBookings.FirstOrDefault(a => a.Booking_No == BN && a.SessionId == checkOutData.Sid); var traveller = checkOutData.Travellers.FirstOrDefault(a => a.Main == true); var customer = dBEntitiy.Customers.FirstOrDefault(a => a.Email == checkOutData.Mail); if (customer != null) { BookingData.Customer_ID = customer.ID.ToString(); } else { Customer cus = new Customer(); cus.Country = traveller.nationality; cus.Date_Of_Birth = traveller.DateOfBirth; cus.Email = checkOutData.Mail; cus.First_Name = traveller.firstName; cus.Last_Name = traveller.lastName; cus.Phone = traveller.phone; cus.Phone_Code = traveller.phoneCode; cus.Salutations = traveller.salutation; dBEntitiy.Customers.Add(cus ); dBEntitiy.SaveChanges(); BookingData.Customer_ID = cus.ID.ToString(); } BookingData.Pax_Name = traveller.firstName + " " + traveller.lastName; BookingData.Booking_Email = checkOutData.Mail; BookingData.Booking_phone = traveller.phone; BookingData.Booking_Phone_Code = traveller.phoneCode; EffectedRows = dBEntitiy.SaveChanges(); return(EffectedRows); } return(0); } catch (Exception ex) { throw ex; } }