Beispiel #1
0
        public void DisplayaRideOffer(RideOfferViewModel offer)
        {
            Console.WriteLine($" OfferId          : {offer.Id} ");
            Console.WriteLine($" Posted By        : {offer.OfferCreatorId} ");
            Console.WriteLine($"");
            Console.WriteLine($" origin City  Id  : {offer.FromCityId} ");
            Console.WriteLine($" Destination  Id  : {offer.ToCityId} ");
            Console.WriteLine($"");
            Console.WriteLine($"origin City       : {cityService.GetCityById(offer.FromCityId).Name}");
            Console.WriteLine($"Destination City  : {cityService.GetCityById(offer.ToCityId).Name}");

            Console.WriteLine($" No of Stops      : {offer.CityIdsOfStops.Count} ");

            foreach (string city in offer.CityIdsOfStops)
            {
                Console.WriteLine($" Stop no {offer.CityIdsOfStops.IndexOf(city) + 1 } : {city} ");
            }
            Console.WriteLine($" Fare for Entire Journey : {offer.EntireJourneyFare}");
            Console.WriteLine($" No of Bookings : {bookingService.GetBookingsOfaOfferId(offer.Id).MapV2D<IEnumerable<BookingViewModel>>().Count()}");
            Console.WriteLine($"");
        }
Beispiel #2
0
        async Task OfferRide(NamedLocation origin, NamedLocation destination)
        {
            if (!(App.Current.Rides.RidesharingState is NoneState currentState))
            {
                return;
            }

            RideOfferViewModel rideOfferViewModel =
                new RideOfferViewModel(
                    async(off) =>
            {
                var offer = off as RideOffer;

                // FIXME: What if current state changed?
                bool success = await currentState.PostOffer(offer);
                await Navigation.PopAsync();

                if (!success)
                {
                    tagRideMap.HomeView(OnSearchBarLocation, OnMapLongPress);

                    await this.GetPageParent()?.DisplayAlert("Failed", "Failed to offer ride.", "Ok");
                }
                else
                {
                    tagRideMap.RideInfoView(
                        new RideInfo(null, null,
                                     new Route(
                                         new Route.Stop[]
                    {
                        new Route.Stop(offer.Trip.Source),
                        new Route.Stop(offer.Trip.Destination)
                    }
                                         )
                                     )
                        );
                }
            },
                    async() =>
            {
                tagRideMap.HomeView(OnSearchBarLocation, OnMapLongPress);

                await Navigation.PopAsync();
            },
                    async(loc, callback) =>
            {
                Page p = await Navigation.PopAsync();
                tagRideMap.LocationSelectionView(loc,
                                                 async(newLoc) =>
                {
                    callback?.Invoke(newLoc);
                    await Navigation.PushAsync(p);
                    tagRideMap.PureMapView();
                });
            },
                    origin,
                    destination);

            await Navigation.PushAsync(
                new ContentPage
            {
                Content = new RideOfferView(rideOfferViewModel)
            }
                );
        }