Beispiel #1
0
        public virtual void AuthorizeDebit(Fare fare)
        {
            var requestDate = DateTime.Now;

            AuthorizeDebit(fare, requestDate);
        }
Beispiel #2
0
 internal double Final_Tube_Fare(string start_point, string end_point)
 {
     return(Fare.Calculate_Final_Fare(start_point, end_point));
 }
        private Fare BuildFlightFare(FareInformation fareInfo)
        {
            Fare fare = new Fare();

            decimal baseFare   = 0;
            decimal changeCost = 0;
            decimal discount   = 0;
            decimal tax        = 0;

            if (fareInfo != null)
            {
                if (fareInfo.AdultFares != null)
                {
                    foreach (var AdultFare in fareInfo.AdultFares)
                    {
                        if (!string.IsNullOrEmpty(AdultFare.BaseAdultFarePerPax))
                        {
                            baseFare += Convert.ToDecimal(AdultFare.BaseAdultFarePerPax) * Convert.ToDecimal(AdultFare.PaxCount);
                        }

                        if (!string.IsNullOrEmpty(AdultFare.DiscountPerPax))
                        {
                            discount += Convert.ToDecimal(AdultFare.DiscountPerPax) * Convert.ToDecimal(AdultFare.PaxCount);
                        }

                        if (!string.IsNullOrEmpty(AdultFare.TaxPerPax))
                        {
                            tax += Convert.ToDecimal(AdultFare.TaxPerPax) * Convert.ToDecimal(AdultFare.PaxCount);
                        }

                        //if (!string.IsNullOrEmpty(AdultFare.ChangeCost))
                        //    changeCost += Convert.ToDecimal(AdultFare.ChangeCost) * Convert.ToDecimal(AdultFare.PaxCount);
                    }
                }

                if (fareInfo.ChildFares != null)
                {
                    foreach (var ChildFare in fareInfo.ChildFares)
                    {
                        if (!string.IsNullOrEmpty(ChildFare.BaseChildFarePerPax))
                        {
                            baseFare += Convert.ToDecimal(ChildFare.BaseChildFarePerPax) * Convert.ToDecimal(ChildFare.PaxCount);
                        }

                        if (!string.IsNullOrEmpty(ChildFare.DiscountPerPax))
                        {
                            discount += Convert.ToDecimal(ChildFare.DiscountPerPax) * Convert.ToDecimal(ChildFare.PaxCount);
                        }
                        ;

                        if (!string.IsNullOrEmpty(ChildFare.TaxPerPax))
                        {
                            tax += Convert.ToDecimal(ChildFare.TaxPerPax) * Convert.ToDecimal(ChildFare.PaxCount);
                        }

                        //if (!string.IsNullOrEmpty(ChildFare.ChangeCost))
                        //    changeCost += Convert.ToDecimal(ChildFare.ChangeCost) * Convert.ToDecimal(ChildFare.PaxCount);
                    }
                }

                if (fareInfo.InfantFares != null)
                {
                    foreach (var InfantFare in fareInfo.InfantFares)
                    {
                        if (!string.IsNullOrEmpty(InfantFare.BaseInfantFarePerPax))
                        {
                            baseFare += Convert.ToDecimal(InfantFare.BaseInfantFarePerPax) * Convert.ToDecimal(InfantFare.PaxCount);
                        }
                        ;

                        if (!string.IsNullOrEmpty(InfantFare.DiscountPerPax))
                        {
                            discount += Convert.ToDecimal(InfantFare.DiscountPerPax) * Convert.ToDecimal(InfantFare.PaxCount);
                        }
                        ;

                        if (!string.IsNullOrEmpty(InfantFare.TaxPerPax))
                        {
                            tax += Convert.ToDecimal(InfantFare.TaxPerPax) * Convert.ToDecimal(InfantFare.PaxCount);
                        }

                        //if (!string.IsNullOrEmpty(InfantFare.ChangeCost))
                        //    changeCost += Convert.ToDecimal(InfantFare.ChangeCost) * Convert.ToDecimal(InfantFare.PaxCount);
                    }
                }
            }

            fare.BaseFare = CurrencyHelper.ToString(currency, baseFare);
            //fare.ChangeCost = CurrencyHelper.ToString(currency, changeCost);
            fare.Discount  = CurrencyHelper.ToString(currency, discount);
            fare.Tax       = CurrencyHelper.ToString(currency, tax);
            fare.TotalFare = CurrencyHelper.ToString(currency, baseFare + tax);

            fare.CurrencyCode = currency;
            //faresForConversion.Add(fare.BaseFare.Replace(",", ""));

            return(fare);
        }
Beispiel #4
0
 /// <summary>
 /// 非同步取得本站與到達站間的票價
 /// </summary>
 /// <param name="arrival">到達站</param>
 /// <param name="trainType">列車類型</param>
 /// <param name="fareType">票價類型</param>
 /// <returns>票價</returns>
 public static async Task <int> GetFaresPriceAsync(this Station THIS, Station arrival, TrainLevels trainType, FareTypes fareType)
 {
     return(await Fare.GetFaresPriceAsync(THIS, arrival, trainType, fareType));
 }
Beispiel #5
0
 void AndGivenTheBuyerSelectsA(Fare fare)
 {
 }
        public ActionResult AgregarServicio(FormCollection form, List <HttpPostedFileBase> foto, string cantidad, string categoria)
        {
            Service servicio = new Service();

            //Obtener datos de los inputs
            string nombreServicio    = form["nombreServicio"];
            string nombrePropietario = form["nombrePropietario"];
            string provincia         = form["provincia"];
            string canton            = form["canton"];
            string distrito          = form["distrito"];
            string pueblo            = form["pueblo"];
            string latitud           = form["latitud"];
            string longuitud         = form["longuitud"];

            //Obtener el usuario que tiene sesion iniciada
            Usuario creador = (Usuario)Session["USER"];

            //Cantidad de tarifas que va a tener el servicio
            int cantidadTarifas = Convert.ToInt32(cantidad);

            //Id de la categoria escogida
            int idCategoria = Convert.ToInt32(categoria);

            servicio.idCreador  = creador.correo;
            servicio.name       = nombreServicio;
            servicio.owner      = nombrePropietario;
            servicio.province   = provincia;
            servicio.canton     = canton;
            servicio.district   = distrito;
            servicio.town       = pueblo;
            servicio.KmDistance = "";
            servicio.latitude   = latitud.ToString();
            servicio.longitude  = longuitud.ToString();
            servicio.idCategory = idCategoria;

            //direcciones en el servidor de las imagenes
            List <string> fotos = new List <string>();

            foreach (var file in foto)
            {
                file.SaveAs(Server.MapPath("~/App_Data/Upload/" + file.FileName));
                string direccion = Server.MapPath("~/App_Data/Upload/" + file.FileName);
                fotos.Add(direccion);
            }

            //datos de las tarifas
            List <Fare> tarifas = new List <Fare>();

            for (int i = 0; i < cantidadTarifas; i++)
            {
                Fare   tarifa      = new Fare();
                string nombreT     = "tarifaNombre" + (i + 1);
                string precio      = "tarifaPrecio" + (i + 1);
                string descripcion = "tarifaDescripcion" + (i + 1);

                tarifa.name        = form[nombreT];
                tarifa.description = form[descripcion];
                tarifa.precio      = Convert.ToInt32(form[precio]);
                tarifas.Add(tarifa);
            }

            servicio.fare = tarifas;


            MongoConnect nombre     = new MongoConnect();
            Service      servicioID = new Service();

            servicioID = nombre.addServiceReturn(servicio, fotos);
            neo.agregarServicio(servicioID);
            neo.categoria_x_Servicio(idCategoria, servicioID);

            //eliminar fotos del servidor
            System.IO.DirectoryInfo di = new DirectoryInfo(Server.MapPath("~/App_Data/Upload/"));

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            return(RedirectToAction("Servicios", "Vendedor"));
        }
Beispiel #7
0
 /// <summary>
 /// 非同步取得本站到到達站的票價資訊
 /// </summary>
 /// <param name="arrival">到達站</param>
 /// <param name="direction">列車方向</param>
 /// <returns>票價資訊</returns>
 public static async Task <Fare[]> GetFaresAsync(this Station THIS, Station arrival, TrainDirection direction)
 {
     return(await Fare.GetFaresAsync(THIS, arrival, direction));
 }
Beispiel #8
0
        public IBSOrderResult CreateIbsOrder(Guid orderId, Address pickupAddress, Address dropOffAddress, string accountNumberString, string customerNumberString,
                                             string companyKey, int ibsAccountId, string name, string phone, string email, int passengers, int?vehicleTypeId, string ibsInformationNote, bool isFutureBooking,
                                             DateTime pickupDate, string[] prompts, int?[] promptsLength, IList <ListItem> referenceDataCompanyList, string market, int?chargeTypeId,
                                             int?requestProviderId, Fare fare, double?tipIncentive, int?tipPercent, string assignVehicleId, bool isHailRequest = false, int?companyFleetId = null)
        {
            _logger.LogMessage(string.Format("IbsCreateOrderService::CreateIbsOrder - assignVehicleId: {0}", assignVehicleId));
            if (_serverSettings.ServerData.IBS.FakeOrderStatusUpdate)
            {
                // Wait 15 seconds to reproduce what happens in real life with the "Finding you a taxi"
                Thread.Sleep(TimeSpan.FromSeconds(15));

                // Fake IBS order id
                return(new IBSOrderResult
                {
                    CreateOrderResult = new Random(Guid.NewGuid().GetHashCode()).Next(90000, 90000000),
                    IsHailRequest = isHailRequest
                });
            }

            int?ibsChargeTypeId;

            if (chargeTypeId == ChargeTypes.CardOnFile.Id ||
                chargeTypeId == ChargeTypes.PayPal.Id)
            {
                ibsChargeTypeId = _serverSettings.ServerData.IBS.PaymentTypeCardOnFileId;
            }
            else if (chargeTypeId == ChargeTypes.Account.Id)
            {
                ibsChargeTypeId = _serverSettings.ServerData.IBS.PaymentTypeChargeAccountId;
            }
            else
            {
                ibsChargeTypeId = _serverSettings.ServerData.IBS.PaymentTypePaymentInCarId;
            }

            var defaultCompany = referenceDataCompanyList.FirstOrDefault(x => x.IsDefault.HasValue && x.IsDefault.Value)
                                 ?? referenceDataCompanyList.FirstOrDefault();

            //if we are in external market or local market but in a different company
            var providerId = (market.HasValue() || companyKey.HasValue()) &&
                             referenceDataCompanyList.Any() && defaultCompany != null
                    ? defaultCompany.Id
                    : requestProviderId;

            var ibsPickupAddress  = Mapper.Map <IbsAddress>(pickupAddress);
            var ibsDropOffAddress = dropOffAddress != null && dropOffAddress.IsValid()
                ? Mapper.Map <IbsAddress>(dropOffAddress)
                : null;

            var customerNumber = GetCustomerNumber(accountNumberString, customerNumberString);

            int?createOrderResult    = null;
            var defaultVehicleType   = _vehicleTypeDao.GetAll().FirstOrDefault();
            var defaultVehicleTypeId = defaultVehicleType != null ? defaultVehicleType.ReferenceDataVehicleId : -1;

            IbsHailResponse ibsHailResult = null;

            if (isHailRequest)
            {
                ibsHailResult = Hail(orderId, providerId, market, companyKey, companyFleetId, pickupAddress, ibsAccountId, name, phone,
                                     email, passengers, vehicleTypeId, ibsChargeTypeId, ibsInformationNote, pickupDate, ibsPickupAddress,
                                     ibsDropOffAddress, accountNumberString, customerNumber, prompts, promptsLength, defaultVehicleTypeId,
                                     tipIncentive, tipPercent, fare);
            }
            else
            {
                createOrderResult = _ibsServiceProvider.Booking(companyKey).CreateOrder(
                    orderId,
                    providerId,
                    ibsAccountId,
                    name,
                    phone,
                    email,
                    passengers,
                    vehicleTypeId,
                    ibsChargeTypeId,
                    ibsInformationNote,
                    pickupDate,
                    ibsPickupAddress,
                    ibsDropOffAddress,
                    accountNumberString,
                    customerNumber,
                    prompts,
                    promptsLength,
                    defaultVehicleTypeId,
                    tipIncentive,
                    tipPercent,
                    assignVehicleId,
                    fare);
            }

            var hailResult = Mapper.Map <OrderHailResult>(ibsHailResult);

            return(new IBSOrderResult
            {
                CreateOrderResult = createOrderResult,
                HailResult = hailResult,
                IsHailRequest = isHailRequest
            });
        }
Beispiel #9
0
        //Daily cap calculation is done on the basis of FromZone and ToZone
        private int GetDailyCap(int fromZone, int toZone)
        {
            Fare item = dbContext.FareDetails.FirstOrDefault(x => x.FromZone == fromZone && x.ToZone == toZone);

            return(item.DailyCap);
        }
 public void Update(Fare fare)
 {
     _repository.Update((IModel)fare);
 }
Beispiel #11
0
        private IbsHailResponse Hail(Guid orderId, int?providerId, string market, string companyKey, int?companyFleetId, Address pickupAddress, int ibsAccountId,
                                     string name, string phone, string email, int passengers, int?vehicleTypeId, int?ibsChargeTypeId, string ibsInformationNote, DateTime pickupDate, IbsAddress ibsPickupAddress,
                                     IbsAddress ibsDropOffAddress, string accountNumberString, int?customerNumber, string[] prompts, int?[] promptsLength, int defaultVehicleTypeId, double?tipIncentive, int?tipPercent, Fare fare)
        {
            // Query only the avaiable vehicles from the selected company for the order
            var availableVehicleService = GetAvailableVehiclesServiceClient(market);
            var availableVehicles       = availableVehicleService.GetAvailableVehicles(market, pickupAddress.Latitude, pickupAddress.Longitude)
                                          .Where(v => v.FleetId == companyFleetId).ToArray();

            if (!availableVehicles.Any())
            {
                // Don't query IBS if we don't find any vehicles
                return(new IbsHailResponse
                {
                    OrderKey = new IbsOrderKey {
                        IbsOrderId = -1, TaxiHailOrderId = orderId
                    }
                });
            }

            var vehicleCandidates = availableVehicles.Select(vehicle => new IbsVehicleCandidate
            {
                CandidateType = VehicleCandidateTypes.VctPimId,
                VehicleId     = vehicle.DeviceName,
                ETADistance   = (int?)vehicle.DistanceToArrival ?? 0,
                ETATime       = (int?)vehicle.Eta ?? 0
            });

            var ibsHailResult = _ibsServiceProvider.Booking(companyKey).Hail(
                orderId,
                providerId,
                ibsAccountId,
                name,
                phone,
                email,
                passengers,
                vehicleTypeId,
                ibsChargeTypeId,
                ibsInformationNote,
                pickupDate,
                ibsPickupAddress,
                ibsDropOffAddress,
                accountNumberString,
                customerNumber,
                prompts,
                promptsLength,
                defaultVehicleTypeId,
                vehicleCandidates,
                tipIncentive,
                tipPercent,
                fare);

            // Fetch vehicle candidates (who have accepted the hail request) only if order was successfully created on IBS
            if (ibsHailResult.OrderKey.IbsOrderId > -1)
            {
                // Need to wait for vehicles to receive hail request
                Thread.Sleep(30000);

                var candidates = _ibsServiceProvider.Booking(companyKey).GetVehicleCandidates(ibsHailResult.OrderKey);
                ibsHailResult.VehicleCandidates = candidates;
            }

            return(ibsHailResult);
        }
 public void Create(Fare fare)
 {
     _repository.Insert((IModel)fare);
 }
Beispiel #13
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AirlineClass != null)
         {
             hashCode = hashCode * 59 + AirlineClass.GetHashCode();
         }
         if (ArrivalAirport != null)
         {
             hashCode = hashCode * 59 + ArrivalAirport.GetHashCode();
         }
         if (ArrivalTime != null)
         {
             hashCode = hashCode * 59 + ArrivalTime.GetHashCode();
         }
         if (CarrierCode != null)
         {
             hashCode = hashCode * 59 + CarrierCode.GetHashCode();
         }
         if (ConjunctionTicket != null)
         {
             hashCode = hashCode * 59 + ConjunctionTicket.GetHashCode();
         }
         if (CouponNumber != null)
         {
             hashCode = hashCode * 59 + CouponNumber.GetHashCode();
         }
         if (Date != null)
         {
             hashCode = hashCode * 59 + Date.GetHashCode();
         }
         if (DepartureTime != null)
         {
             hashCode = hashCode * 59 + DepartureTime.GetHashCode();
         }
         if (EndorsementOrRestriction != null)
         {
             hashCode = hashCode * 59 + EndorsementOrRestriction.GetHashCode();
         }
         if (ExchangeTicket != null)
         {
             hashCode = hashCode * 59 + ExchangeTicket.GetHashCode();
         }
         if (Fare != null)
         {
             hashCode = hashCode * 59 + Fare.GetHashCode();
         }
         if (FareBasis != null)
         {
             hashCode = hashCode * 59 + FareBasis.GetHashCode();
         }
         if (Fee != null)
         {
             hashCode = hashCode * 59 + Fee.GetHashCode();
         }
         if (FlightNumber != null)
         {
             hashCode = hashCode * 59 + FlightNumber.GetHashCode();
         }
         if (Number != null)
         {
             hashCode = hashCode * 59 + Number.GetHashCode();
         }
         if (OriginAirport != null)
         {
             hashCode = hashCode * 59 + OriginAirport.GetHashCode();
         }
         if (PassengerClass != null)
         {
             hashCode = hashCode * 59 + PassengerClass.GetHashCode();
         }
         if (ServiceClass != null)
         {
             hashCode = hashCode * 59 + ServiceClass.GetHashCode();
         }
         if (StopoverCode != null)
         {
             hashCode = hashCode * 59 + StopoverCode.GetHashCode();
         }
         if (Taxes != null)
         {
             hashCode = hashCode * 59 + Taxes.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #14
0
        /// <summary>
        /// Returns true if AirlineFlightLeg instances are equal
        /// </summary>
        /// <param name="other">Instance of AirlineFlightLeg to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AirlineFlightLeg other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AirlineClass == other.AirlineClass ||
                     AirlineClass != null &&
                     AirlineClass.Equals(other.AirlineClass)
                     ) &&
                 (
                     ArrivalAirport == other.ArrivalAirport ||
                     ArrivalAirport != null &&
                     ArrivalAirport.Equals(other.ArrivalAirport)
                 ) &&
                 (
                     ArrivalTime == other.ArrivalTime ||
                     ArrivalTime != null &&
                     ArrivalTime.Equals(other.ArrivalTime)
                 ) &&
                 (
                     CarrierCode == other.CarrierCode ||
                     CarrierCode != null &&
                     CarrierCode.Equals(other.CarrierCode)
                 ) &&
                 (
                     ConjunctionTicket == other.ConjunctionTicket ||
                     ConjunctionTicket != null &&
                     ConjunctionTicket.Equals(other.ConjunctionTicket)
                 ) &&
                 (
                     CouponNumber == other.CouponNumber ||
                     CouponNumber != null &&
                     CouponNumber.Equals(other.CouponNumber)
                 ) &&
                 (
                     Date == other.Date ||
                     Date != null &&
                     Date.Equals(other.Date)
                 ) &&
                 (
                     DepartureTime == other.DepartureTime ||
                     DepartureTime != null &&
                     DepartureTime.Equals(other.DepartureTime)
                 ) &&
                 (
                     EndorsementOrRestriction == other.EndorsementOrRestriction ||
                     EndorsementOrRestriction != null &&
                     EndorsementOrRestriction.Equals(other.EndorsementOrRestriction)
                 ) &&
                 (
                     ExchangeTicket == other.ExchangeTicket ||
                     ExchangeTicket != null &&
                     ExchangeTicket.Equals(other.ExchangeTicket)
                 ) &&
                 (
                     Fare == other.Fare ||
                     Fare != null &&
                     Fare.Equals(other.Fare)
                 ) &&
                 (
                     FareBasis == other.FareBasis ||
                     FareBasis != null &&
                     FareBasis.Equals(other.FareBasis)
                 ) &&
                 (
                     Fee == other.Fee ||
                     Fee != null &&
                     Fee.Equals(other.Fee)
                 ) &&
                 (
                     FlightNumber == other.FlightNumber ||
                     FlightNumber != null &&
                     FlightNumber.Equals(other.FlightNumber)
                 ) &&
                 (
                     Number == other.Number ||
                     Number != null &&
                     Number.Equals(other.Number)
                 ) &&
                 (
                     OriginAirport == other.OriginAirport ||
                     OriginAirport != null &&
                     OriginAirport.Equals(other.OriginAirport)
                 ) &&
                 (
                     PassengerClass == other.PassengerClass ||
                     PassengerClass != null &&
                     PassengerClass.Equals(other.PassengerClass)
                 ) &&
                 (
                     ServiceClass == other.ServiceClass ||
                     ServiceClass != null &&
                     ServiceClass.Equals(other.ServiceClass)
                 ) &&
                 (
                     StopoverCode == other.StopoverCode ||
                     StopoverCode != null &&
                     StopoverCode.Equals(other.StopoverCode)
                 ) &&
                 (
                     Taxes == other.Taxes ||
                     Taxes != null &&
                     Taxes.Equals(other.Taxes)
                 ));
        }
Beispiel #15
0
 void TheBuyerSelectsA(Fare fare)
 {
 }
Beispiel #16
0
 /// <summary>
 /// 非同步取得本站到到達站的票價資訊
 /// </summary>
 /// <param name="arrival">到達站</param>
 /// <returns>票價資訊</returns>
 public static async Task <Fare[]> GetFaresAsync(this Station THIS, Station arrival)
 {
     return(await Fare.GetFaresAsync(THIS, arrival));
 }
        void TheBuyerSelectsA(Fare fare)
        {

        }
Beispiel #18
0
        public ActionResult Ordenes()
        {
            Usuario user          = (Usuario)Session["USER"];
            var     listaSqlOrden = new List <Orden>();
            var     listaOrden    = new List <Order>();

            if (ModelState.IsValid)
            {
                using (serviciosCREntities db = new serviciosCREntities())
                {
                    listaSqlOrden = db.Ordens.Where(a => a.idCliente.Equals(user.idUsuario)).ToList();

                    if (listaSqlOrden != null)
                    {
                        // Llenar lista de Order
                        foreach (Orden o in listaSqlOrden)
                        {
                            Order order = new Order();
                            order.fechaHora = o.fechaHora;
                            order.idCliente = o.idCliente;
                            order.idOrden   = o.idOrden;
                            listaOrden.Add(order);
                        }

                        int idOrden;
                        List <ServiciosPorOrden> sopList;
                        int i, j;
                        for (i = 0; i < listaOrden.Count(); ++i)
                        {
                            idOrden = listaOrden[i].idOrden;
                            sopList = db.ServiciosPorOrdens.Where(a => a.idOrden.Equals(idOrden)).ToList();
                            for (j = 0; j < sopList.Count(); ++j)
                            {
                                MongoConnect mongo   = new MongoConnect();
                                Service      service = mongo.getid((sopList[j].idServicio).ToString());

                                Fare fare = new Fare();
                                foreach (var f in service.fare)
                                {
                                    if ((sopList[j].idTarifa.ToString()).Equals(f.id.ToString()))
                                    {
                                        fare           = f;
                                        fare.serviceId = sopList[j].idServicio;
                                        fare.qty       = sopList[j].cantidad;
                                    }
                                }
                                Tuple <Service, Fare> item = new Tuple <Service, Fare>(service, fare);
                                listaOrden[i].orderList.Add(item);
                            }
                        }
                    }
                    else
                    {
                        listaOrden    = null;
                        ViewBag.Error = "Usted no tiene ninguna orden registrada";
                    }
                }
            }
            //Si no hay ordenes retorna null
            return(View(listaOrden));
        }