GetAvailabilityRequest GetRequestInfo() { // Get the Json from the POST. string strJson = String.Empty; HttpContext context = HttpContext.Current; context.Request.InputStream.Position = 0; using (StreamReader inputStream = new StreamReader(context.Request.InputStream)) { strJson = inputStream.ReadToEnd(); } // Deserialize the Json. GetAvailabilityRequest req = JsonConvert.DeserializeObject <GetAvailabilityRequest>(strJson); return(req); }
public IEnumerable <Availability> GetAvailabilities(GetAvailabilityRequest request) { bool includeSquadId = request.SquadId.HasValue && !request.SquadId.Value.IsEmpty(); bool includePlayerId = request.PlayerId.HasValue && !request.PlayerId.Value.IsEmpty(); var sql = GetAvailabilitiesSql(includeSquadId, includePlayerId, request.Year); DynamicParameters p = new DynamicParameters(); p.Add("@ClubGuid", request.ClubId.ToString()); if (includeSquadId) { p.Add("@SquadGuid", request.SquadId.ToString()); } if (includePlayerId) { p.Add("@PlayerGuid", request.PlayerId.ToString()); } if (request.Year.HasValue) { p.Add("@Year", request.Year); } using (var connection = connectionFactory.Connect()) { connection.Open(); var reader = connection.Query(sql, p).Cast <IDictionary <string, object> >(); var availabilities = reader.Select <dynamic, Availability>( row => new Availability(Guid.Parse(row.AvailabilityGuid.ToString()), Guid.Parse(row.PlayerGuid.ToString())) { AvailabilityStatus = (AvailabilityStatus?)row.AvailabilityId, DateFrom = row.DateFrom, DateTo = (DateTime?)row.DateTo, Notes = row.Notes, PlayerName = row.PlayerName, SquadName = row.SquadName }).ToList(); return(availabilities); } }
public BookingManager.GetAvailabilityResponse GetAvailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg,int nightstay) { BookingManager.GetAvailabilityRequest gar = new GetAvailabilityRequest();//this is from service contracts gar.Signature = signature;//i need to use the signature property to sign in gar.TripAvailabilityRequest = new TripAvailabilityRequest(); // call the method TripAvailabilityRequest from the GetAvaialbilityRequest class // gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array PaxPriceType[] priceTypes; // 9- not passed in method but i have to do this step because it is a required parameter priceTypes = new PaxPriceType[2];//this is to define the type of passenger travelling, whether adt or chd. But to check how many of each then i need to use the Pax Count or passenger info for (int j = 0; j < priceTypes.Length; j++) { priceTypes[j] = new PaxPriceType(); if (j < 1) // this sets the first item of array to an adult { priceTypes[j].PaxType = "ADT"; } else // this sets the second item to child { priceTypes[j].PaxType = "CHD"; } } if (nightstay == 0) { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array } else { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[2]; } for (int i = 0; i < gar.TripAvailabilityRequest.AvailabilityRequests.Length; i++) { BookingManager.AvailabilityRequest ar = new AvailabilityRequest();//this is from data contracts //AvailabilityRequest []ar = new AvailabilityRequest[2]; //ar[0] = new AvailabilityRequest(); //ar[1] = new AvailabilityRequest(); if (sourceorg.Length > 0)// if this value is passed in then ar.SourceOrganization (parameter) will be the next line { ar.SourceOrganization = sourceorg; //1 } ar.PaxCount = (short)(numadt + numchd); //2 ar.CurrencyCode = currency;//7 ar.PaxPriceTypes = priceTypes; if (faretype.Equals("ST")) { ar.AvailabilityType = AvailabilityType.Standby; } else { ar.AvailabilityType = AvailabilityType.Default; } ar.AvailabilityFilter = AvailabilityFilter.Default; if (i == 0)//check if it is a one way trip or return trip { ar.DepartureStation = dstation; ar.ArrivalStation = astation; ar.BeginDate = startdate; ar.EndDate = endate; } else { ar.DepartureStation = astation; ar.ArrivalStation = dstation; ar.BeginDate = endate; ar.EndDate = endate; //ar.DepartureStations = new string[1];// for return //ar.DepartureStations[0] = astation; //ar.ArrivalStations = new string[1]; //ar.ArrivalStations[0] = dstation; } ar.FlightType = FlightType.All;//10 ar.Dow = DOW.Daily;//11 ar.MaximumConnectingFlights = 5;//14--since flight type is direct ar.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable;//13..this will still return me a result set if my currency is set to null although the function demands i pass a value in as the filter is based on flights ar.IncludeTaxesAndFees = true; ar.SSRCollectionsMode = SSRCollectionsMode.Leg;//this i sto tell me the list of SSR avaialble for purchase ar.FareClassControl = FareClassControl.CompressByProductClass; ar.InboundOutbound = InboundOutbound.None; ar.FareTypes = new String[1];// must be RE-regular or ST for standby fares ar.FareTypes[0] = faretype; gar.TripAvailabilityRequest.AvailabilityRequests[i] = ar;//get all the parameters from getavailability field and put it back to ar. } DateTime startTiming = DateTime.Now; BookingManager.GetAvailabilityResponse garesponse = clientapi.GetAvailability(gar); DateTime endTiming = DateTime.Now; Console.WriteLine("Timing: " + endTiming.Subtract(startTiming).Seconds + "Seconds"); if (garesponse.GetTripAvailabilityResponse.Schedules.Length > 0 && garesponse.GetTripAvailabilityResponse.Schedules[0].Length > 0)//schedules refer to the journey markets returned from the search { Console.WriteLine("{0} journey by availability", garesponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys.Length);// return response is always in a 2 dimensional array } else { Console.WriteLine("No journey found"); garesponse = null; } return garesponse; }
public static void GetAvailability1(string source, string destination, string ddate, string returndate, string waytype, string noofPassenger) { IBookingManager bookingManager = new BookingManagerClient(); string signature = Login(); GetAvailabilityRequest gar = new GetAvailabilityRequest(); TripAvailabilityRequest tar = new TripAvailabilityRequest(); AvailabilityRequest ar = new AvailabilityRequest(); ar.DepartureStation = source; // "DEL";// HttpContext.Current.Session["origin"].ToString(); ar.ArrivalStation = destination; // "BOM";// HttpContext.Current.Session["destination"].ToString(); //string[] date = ddate.Split('/');// HttpContext.Current.Session["ddate"].ToString().Split('/'); //int year = int.Parse(date[2]), month = int.Parse(date[1]), day = int.Parse(date[0]); int year = int.Parse(ddate.Substring(0, 4)), month = int.Parse(ddate.Substring(4, 2)), day = int.Parse(ddate.Substring(6)); ar.BeginDate = new DateTime(year, month, day); //Convert.ToDateTime("2015-07-07"); ar.EndDate = new DateTime(year, month, day); ar.FlightType = FlightType.Direct; //ar.FlightNumber = b.FlightNo.Length == 3 ? " " + b.FlightNo : b.FlightNo; int pax = Convert.ToInt16(noofPassenger);//+ Convert.ToInt16(page.child); ar.PaxCount = Convert.ToSByte(pax); ar.Dow = DOW.Daily; ar.CurrencyCode = "INR"; ar.AvailabilityType = AvailabilityType.Default; //change 15 oct 2015 ar.MaximumConnectingFlights = 5; ar.AvailabilityFilter = AvailabilityFilter.Default; //change ar.FareClassControl = FareClassControl.LowestFareClass; ar.MinimumFarePrice = 0; ar.MaximumFarePrice = 0; ar.SSRCollectionsMode = SSRCollectionsMode.None; ar.InboundOutbound = InboundOutbound.None; ar.NightsStay = 0; ar.IncludeAllotments = false; ar.FareTypes = new string[1];// change ar.FareTypes[0] = "R"; //ar.FareTypes = new string[1];// change //ar.FareTypes[0] = "BD"; //ar.ProductClasses = new string[1]; //ar.ProductClasses[0] = "BD"; PaxPriceType[] priceTypes = new PaxPriceType[ar.PaxCount]; for (int i = 0; i < ar.PaxCount; i++) { priceTypes[i] = new PaxPriceType(); priceTypes[i].PaxType = "ADT"; priceTypes[i].PaxDiscountCode = String.Empty; } ar.PaxPriceTypes = priceTypes; ar.IncludeTaxesAndFees = false; ar.FareRuleFilter = FareRuleFilter.Default; ar.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; if (!string.IsNullOrEmpty(returndate))// for round trip { AvailabilityRequest rar = new AvailabilityRequest(); rar.DepartureStation = destination; // "DEL";// HttpContext.Current.Session["origin"].ToString(); rar.ArrivalStation = source; // "BOM";// HttpContext.Current.Session["destination"].ToString(); //string[] date = ddate.Split('/');// HttpContext.Current.Session["ddate"].ToString().Split('/'); //int year = int.Parse(date[2]), month = int.Parse(date[1]), day = int.Parse(date[0]); int ryear = int.Parse(returndate.Substring(0, 4)), rmonth = int.Parse(returndate.Substring(4, 2)), rday = int.Parse(returndate.Substring(6)); rar.BeginDate = new DateTime(ryear, rmonth, rday); //Convert.ToDateTime("2015-07-07"); rar.EndDate = new DateTime(ryear, rmonth, rday); rar.FlightType = FlightType.Direct; //ar.FlightNumber = b.FlightNo.Length == 3 ? " " + b.FlightNo : b.FlightNo; int rpax = Convert.ToInt16(noofPassenger);//+ Convert.ToInt16(page.child); rar.PaxCount = Convert.ToSByte(rpax); rar.Dow = DOW.Daily; rar.CurrencyCode = "INR"; rar.AvailabilityType = AvailabilityType.Default; //change 15 oct 2015 rar.MaximumConnectingFlights = 5; rar.AvailabilityFilter = AvailabilityFilter.Default; //change rar.FareClassControl = FareClassControl.LowestFareClass; rar.MinimumFarePrice = 0; rar.MaximumFarePrice = 0; rar.SSRCollectionsMode = SSRCollectionsMode.None; rar.InboundOutbound = InboundOutbound.None; rar.NightsStay = 0; rar.IncludeAllotments = false; rar.FareTypes = new string[1];// change rar.FareTypes[0] = "R"; //ar.FareTypes = new string[1];// change //ar.FareTypes[0] = "BD"; //ar.ProductClasses = new string[1]; //ar.ProductClasses[0] = "BD"; PaxPriceType[] rpriceTypes = new PaxPriceType[ar.PaxCount]; for (int i = 0; i < ar.PaxCount; i++) { rpriceTypes[i] = new PaxPriceType(); rpriceTypes[i].PaxType = "ADT"; rpriceTypes[i].PaxDiscountCode = String.Empty; } rar.PaxPriceTypes = rpriceTypes; rar.IncludeTaxesAndFees = false; rar.FareRuleFilter = FareRuleFilter.Default; rar.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; tar.AvailabilityRequests = new AvailabilityRequest[2]; tar.AvailabilityRequests[0] = ar; tar.AvailabilityRequests[1] = rar; } else { tar.AvailabilityRequests = new AvailabilityRequest[1]; tar.AvailabilityRequests[0] = ar; } tar.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; gar.TripAvailabilityRequest = tar; gar.Signature = signature; gar.ContractVersion = 0; GetAvailabilityResponse gare = bookingManager.GetAvailability(gar); //if (waytype == "1") GetPrice(signature, gare, noofPassenger); //if (waytype == "2") // GetPriceReturn(signature, gare,page); }
public void TestBookFlow() { Alphareds.Module.EANRapidHotels.RapidServices.HotelManagerClient rapidHotels = new Alphareds.Module.EANRapidHotels.RapidServices.HotelManagerClient(); var roomModel = GetRoomModelWithResult(out SearchHotelModel hotelModel, out string hotelId); var roomResult = roomModel.Result; var bookRequest = new Alphareds.Module.EANRapidHotels.RapidServices.CreateBookingRequest { UserAgent = roomModel.CustomerUserAgent, CustomerIp = roomModel.CustomerIpAddress, Opt_Hold = Hold.False, }; bookRequest.Rooms = new List <GuestRoom1>(); var roomList = roomResult.HotelRoomInformationList.SelectMany(x => x.roomAvailabilityDetailsList); var testPickCount = roomList.Count(); testPickCount = (int)Math.Floor(testPickCount * 0.3); testPickCount = testPickCount <= 0 ? 1 : testPickCount; var pickedRoomList = roomList.OrderBy(x => Guid.NewGuid()).Take(testPickCount); List <Task <GetCurrentPriceResponse> > getPreBookPrice = new List <Task <GetCurrentPriceResponse> >(); #region Test Rapid Get Room var testRoomReq = new GetAvailabilityRequest { UserAgent = roomModel.CustomerUserAgent, CustomerIp = roomModel.CustomerIpAddress, Opt_CustomerSessionId = roomModel.CustomerSessionId, CheckIn = new DateTime(2018, 12, 10), //hotelModel.ArrivalDate, CheckOut = new DateTime(2018, 12, 15), //hotelModel.DepartureDate, Currency = hotelModel.CurrencyCode, Opt_Token = "REhZAQsABAMGQggMV1pFAV1YVA5cZhBYEgNKH0ZdF105RR9DUAQABlIFTAhAQFxVWhBFBQpWGlwDHFV3AEBVR0dCWF5TQW9GUhFHDFtaPl9cDA1UUFFTUA5WHVIDCgIVBAdQBxoAUAUKGQJZDQ0CUFgFVl0FBx8WUg9WRWsFWwVXWFVfDUJWBkRREgcSElVASghWXz1RBQVSAVdXAwRVABgBV1deGFYGBQAcXlcGVx9SA1dbVgMEVAcMVgMXWVJXVEIDUAELXFZMYWoVRgdBXGZfEkFRXl1eEkdRCFdHOlYLFFsWCgtdBA1MXllbEVQPZ1tWCE4VUwZaA0cEElICZxENWVFeAAVSD0sAVhkIU2FRB0QLJAYFHQRzVFpMBgtcakNRClhGVRAIR1tWQQtHQhhuUFgAAA51PxADWEFQAQkGQltcBwBbWQ0NVwgFWRlUUB5XUUNDU0FMClxKPRRCDl5YDgdnUQdbAgQFVA1cFFIXExQAXwEfXig_MBFaAxBZVUxZC1FqV1tWCg8HWAsAQ1sNUAFbVhdNW1QJCA0ZUgpLAFMVdlEBAF8XTAkJVwUCDF0EXFUBVA==", //Opt_FilterResult = new Options //{ // //Opt_RateOption = RateOption.net_rates, // Opt_Include = Include.all_rates, // Opt_RateOption = RateOption.net_rates, // Opt_Filter = Filter.expedia_collect, //}, Destination = null, //hotelModel.Destination, CountryCode = "MY", PropertyID = new List <string> { "9626874" }, SalesEnvironment = SalesEnvironment.hotel_only, SalesChannel = SalesChannel.website, SortType = SortType.preferred, Occupancy = new List <GuestRoom> { new GuestRoom { TotalAdults = 2, NumberOfChildrenAge = new List <int>(), } , new GuestRoom { TotalAdults = 2, NumberOfChildrenAge = new List <int>(), } } }; var roomRateRapidTest = rapidHotels.GetPropertyRoomRatesAndAvailability(testRoomReq); #endregion var test2 = roomRateRapidTest.result[0].rooms.Where(x => x.rates.Any(s => s.bed_groups.Count > 1)); foreach (var item in pickedRoomList) { var roomRateRapid = rapidHotels.GetPropertyRoomRatesAndAvailability(new GetAvailabilityRequest { UserAgent = roomModel.CustomerUserAgent, CustomerIp = roomModel.CustomerIpAddress, Opt_CustomerSessionId = roomModel.CustomerSessionId, CheckIn = hotelModel.ArrivalDate, CheckOut = hotelModel.DepartureDate, Currency = hotelModel.CurrencyCode, Destination = hotelModel.Destination, CountryCode = "MY", PropertyID = new List <string> { hotelId }, SalesEnvironment = SalesEnvironment.hotel_only, SalesChannel = SalesChannel.website, SortType = SortType.preferred, Occupancy = new List <GuestRoom> { new GuestRoom { TotalAdults = 2 } , new GuestRoom { TotalAdults = 2 } } }); var _roomReq = new GetCurrentPriceRequest { UserAgent = roomModel.CustomerUserAgent, CustomerIp = roomModel.CustomerIpAddress, Opt_CustomerSessionId = roomModel.CustomerSessionId, PropertyID = Convert.ToInt32(hotelId), RateID = item.RateInfos.FirstOrDefault()?.Rooms.FirstOrDefault()?.rateKey, RoomID = item.roomTypeCode, Token = item.BetTypes.FirstOrDefault()?.id, }; getPreBookPrice.Add(rapidHotels.GetCurrentPriceForPreBookingAsync(_roomReq)); bookRequest.Rooms.Add(new GuestRoom1 { Email = "*****@*****.**", Opt_Title = "MR", Family_Name = "TEST", Given_Name = "TEST", Phone = "1234567", Smoking = Smoking.None, Opt_Special_Request = "Test Special Request", Number_Of_Adults = hotelModel.NoOfAdult, }); } for (int i = 0; i < getPreBookPrice.Count; i++) { var bookReq = Task.WaitAny(getPreBookPrice.ToArray()); var _tskCompleted = getPreBookPrice[bookReq]; if (!_tskCompleted.IsCanceled && !_tskCompleted.IsFaulted && _tskCompleted.IsCompleted) { var _result = _tskCompleted.Result; if (_result.Errors?.ErrorMessage?.Length > 0) { break; } } if (getPreBookPrice.Remove(_tskCompleted)) { // Minus for loop index. i = i - 1; } } var res = rapidHotels.CreateBooking(bookRequest); Assert.IsTrue(res?.itinerary_id?.Length > 0, "Create Booking Failed."); }
public GetAvailabilityResponse GetAvailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg, int nightstay) { GetAvailabilityRequest gar = new GetAvailabilityRequest(); gar.Signature = signature; gar.TripAvailabilityRequest = new TripAvailabilityRequest(); PaxPriceType[] priceTypes; // 9- not passed in method but i have to do this step because it is a required parameter priceTypes = new PaxPriceType[2];// this is to define type of passenger travelling, must be adt and chd-also in sell request for (int j = 0; j < priceTypes.Length; j++) { priceTypes[j] = new PaxPriceType(); if (j < 1) { priceTypes[j].PaxType = "ADT"; } else { priceTypes[j].PaxType = "CHD"; } } if (nightstay == 0) { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array } else { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[2]; } for (int i = 0; i < gar.TripAvailabilityRequest.AvailabilityRequests.Length; i++) { BookingManager.AvailabilityRequest ar = new AvailabilityRequest(); if (sourceorg.Length > 0)// if this value is passed in then ar.SourceOrganization (parameter) will be the next line { ar.SourceOrganization = sourceorg; //1 } gar.TripAvailabilityRequest.AvailabilityRequests[i] = ar; ar.PaxCount = (short)(numadt + numchd); //2 ar.CurrencyCode = currency;//7 ar.PaxPriceTypes = priceTypes; ar.AvailabilityType = AvailabilityType.Default;// if i do not put anything, it is defaulted as Availability Type can be a enum list ar.AvailabilityFilter = AvailabilityFilter.Default;// if i do not put if (i == 0)//check if it is a one way trip or return trip { ar.DepartureStation = dstation; ar.ArrivalStation = astation; ar.BeginDate = startdate; ar.EndDate = endate; } else { ar.DepartureStation = astation; ar.ArrivalStation = dstation; ar.BeginDate = endate; ar.EndDate = endate; } ar.FlightType = FlightType.All; ar.Dow = DOW.Daily; ar.MaximumConnectingFlights = 5;//if direct, then default the value to 0; ar.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable; ar.IncludeTaxesAndFees = true; ar.SSRCollectionsMode = SSRCollectionsMode.Leg;//return the SSR available by segment ar.FareClassControl = FareClassControl.CompressByProductClass; ar.InboundOutbound = InboundOutbound.None; ar.FareTypes = new String[1];//either RE-regular fare or JP for japan wholesaler ar.FareTypes[0] = faretype;// put this back to the parameter in Get Availability Response } GetAvailabilityResponse garesponse = clientapi.GetAvailability(gar); if (garesponse.GetTripAvailabilityResponse.Schedules.Length > 0 && garesponse.GetTripAvailabilityResponse.Schedules[0].Length > 0)//schedules refer to the journey markets returned from the search { Console.WriteLine("{0} journey by availability", garesponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys.Length);// return response is always in a 2 dimensional array } else { Console.WriteLine("No journey found"); garesponse = null; } return garesponse; }