Esempio n. 1
0
 /// <summary>
 ///     Handles the communication between client and Rome2rio api.
 /// </summary>
 /// <param name="req">
 ///     Parameters for the request include coordinates of origin and destination,
 ///     arrival and return dates, external flight options and filters.
 /// </param>
 /// <param name="requestFlags">
 ///     Filters the response segment types.
 /// </param>
 internal Rome2RioComm(D2DRequest req, int requestFlags)
 {
     _requestFlags = requestFlags;
     _req = req;
     _resp = new Door2DoorResponse();
 }
Esempio n. 2
0
        /// <summary>
        /// If it is roundtrip and a <see cref="Door2DoorCore.Types.Door2DoorRequest.OuterHotelOption.OuterHotelOption"/> is informed, calculates the taxis amount.
        /// </summary>
        private void BuildItineraryStay()
        {
            int daysTotals = 0;
            if (_req.chosenStay.completeStay)
                daysTotals = Math.Abs((_resp.LegResponse[0].Routes[0].Segments[_resp.LegResponse[0].Routes[0].Segments.Length - 1].ArrivalDateTime.Value - _resp.LegResponse[1].Routes[0].Segments[0].DepartureDateTime.Value).Days);
            else
                daysTotals = Math.Abs((_req.chosenStay.checkoutDate - _req.chosenStay.checkinDate).Days);
            if (daysTotals > 0)
            {
                Door2DoorResponse stayResp = new Door2DoorResponse();
                using (Rome2RioComm comm = new Rome2RioComm(_req, BuildSearchRequestFlags(true)))
                {
                    stayResp = comm.Download(true);
                }

                decimal valorTaxiIda = 0M;
                foreach (Route route in stayResp.LegResponse[0].Routes)
                {
                    if (route.Name.ToLower().Equals("taxi"))
                    {
                        valorTaxiIda = route.IndicativePrice.Price;
                        break;
                    }
                }
                decimal valorTaxiVolta = 0M;
                foreach (Route route in stayResp.LegResponse[1].Routes)
                {
                    if (route.Name.ToLower().Equals("taxi"))
                    {
                        valorTaxiVolta = route.IndicativePrice.Price;
                        break;
                    }
                }

                int nrTaxisIda = valorTaxiIda > 0 ? daysTotals : 0;
                int nrTaxisVolta = valorTaxiVolta > 0 ? daysTotals : 0;
                _resp.NumberOfTaxisOnStay = nrTaxisIda + nrTaxisVolta;
                _resp.TotalPriceOfLocalTaxi = valorTaxiIda * daysTotals + valorTaxiVolta * daysTotals;
                _resp.TotalPriceOfHotel = _req.chosenStay.totalPrice;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 public void Dispose()
 {
     _req = null;
     _resp = null;
 }