Exemplo n.º 1
0
        public decimal Calculate(RideHistory ride)
        {
            decimal totalPrice = 0;
            var     stateId    = 2; // NY TODO: Get value from UI
            var     taxiRate   = _taxiRateRepository.GetTaxiRateByStateId(stateId);

            var timedUnitVal    = ride.NumberOfMinutesIdleOrGoingAboveSixMph / taxiRate.TimedUnitsPerMinute;
            var distanceUnitVal = ride.TotalMilesGoingBelowSixMph / taxiRate.DistanceUnitsPerMile;

            totalPrice += taxiRate.InitialEntryFee;
            totalPrice += (timedUnitVal + distanceUnitVal) * taxiRate.UnitReate;
            totalPrice += taxiRate.StateTaxSurcharge;

            if (ride.StartDateTime.IsPeakHours())
            {
                totalPrice += taxiRate.PeakHoursSurcharge;
            }

            if (ride.StartDateTime.IsNightHours())
            {
                totalPrice += taxiRate.NightTimeSurcharge;
            }

            return(totalPrice);
        }
Exemplo n.º 2
0
        async void OnConfirm(object sender, EventArgs e)
        {
            Ride     ride;
            TempData data          = SQLite.ReadTempData();
            string   sessionKey    = data.sessionKey;
            string   fromLatitude  = data.fromLat;
            string   fromLongitude = data.fromLng;
            string   toLatitude    = data.toLat;
            string   toLongitude   = data.toLng;

            Console.WriteLine(System.DateTime.Today);
            ride          = new Ride(fromLatitude, fromLongitude, toLatitude, toLongitude, sessionKey);
            ride.function = "orderRide";
            object obj = SynchronousSocketClient.StartClient("orderRide", ride);

            ride = (Ride)obj;
            Console.WriteLine("Response: " + ride.response);
            RideDetails details = JsonConvert.DeserializeObject <RideDetails>(ride.response);
            RideHistory history = new RideHistory()
            {
                driverID = details.driver, user = Convert.ToString(App.Current.Properties["user"]), price = data.price, rating = "N/A", rideDate = details.date
            };

            SQLite.ConnectDatabase();
            SQLite.InsertHistoryData(history);
            await this.DisplayAlert("Ride", "Your taxi is on it's way. ETA: " + details.time, "OK");

            await Navigation.PopToRootAsync();
        }
        internal void UpdateCell(RideHistory history)
        {
            pickupText.Text      = history.PickupAddress;
            destinationText.Text = history.DestinationAddress;
            dateText.Text        = history.Created_At.ToString("hh:mm tt, dddd, dd mmmm, yyyy");
            faresAmountText.Text = "$" + history.Fares.ToString();

            if (history.Status == "ended")
            {
                statusText.Text = "Completed";
            }
        }
Exemplo n.º 4
0
        public void GetRideHistory()
        {
            if (tripKeys.Count == 0)
            {
                return;
            }


            foreach (string key in tripKeys)
            {
                DatabaseReference tripRef = Database.DefaultInstance.GetRootReference().GetChild("rideRequest/" + key);
                tripRef.ObserveSingleEvent(DataEventType.Value, (DataSnapshot snapshot) =>
                {
                    if (snapshot.GetValue <NSObject>() != NSNull.Null)
                    {
                        if (snapshot.GetChildSnapshot("status").GetValue <NSObject>() != NSNull.Null)
                        {
                            var rideItem = new RideHistory();

                            rideItem.Status             = snapshot.GetChildSnapshot("status").GetValue <NSObject>().ToString();
                            rideItem.DestinationAddress = snapshot.GetChildSnapshot("destination_address").GetValue <NSObject>().ToString();
                            rideItem.PickupAddress      = snapshot.GetChildSnapshot("pickup_address").GetValue <NSObject>().ToString();
                            rideItem.Created_At         = DateTime.Parse(snapshot.GetChildSnapshot("created_at").GetValue <NSObject>().ToString());

                            if (snapshot.GetChildSnapshot("fares").GetValue <NSObject>() != NSNull.Null)
                            {
                                rideItem.Fares = double.Parse(snapshot.GetChildSnapshot("fares").GetValue <NSObject>().ToString());
                            }
                            else
                            {
                                rideItem.Fares = 0;
                            }

                            rideHistories.Add(rideItem);
                            historyTableView.ReloadData();
                        }
                    }
                });
            }
        }