Ejemplo n.º 1
0
        /// <summary>
        /// Returns the response from rome2rio
        /// </summary>
        /// <param name="getNewResponse">
        ///     If it should get the response from rome2rio or used the stored one, if available
        /// </param>
        private void GetRome2RioResponse(bool getNewResponse)
        {
            if (getNewResponse || _resp == null)
            {
                using (Rome2RioComm comm = new Rome2RioComm(_req, BuildSearchRequestFlags(false)))
                {
                    _resp = comm.Download();
                }
            }
            BuildCompleteItinerarySchedule();

            if (_req.desiredInboundDate.HasValue) //tem volta
            {
                if (_req.chosenStay != null)
                {
                    // se nao é a estadia completa, as datas de checkin e checkout devem que ser validas
                    if (_req.chosenStay.completeStay ||
                        (!_req.chosenStay.completeStay && _req.chosenStay.checkinDate > _req.desiredOutboundDate && _req.chosenStay.checkoutDate < _req.desiredInboundDate))
                    {
                        BuildItineraryStay();
                    }
                }
            }
        }
Ejemplo 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;
            }
        }