Exemple #1
0
        private static string ResolveNamedLocation(Country country, NamedLocation namedLocation, string location)
        {
            // If the location is the displayName then don't flip.

            if (string.Compare(location, namedLocation.Name, StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return(location);
            }

            // If the location is just a case variation on the full string representation then don't flip.

            if (string.Compare(location, namedLocation.ToString(), StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                return(location);
            }

            // If it is using one of the location synonyms then don't flip.

            if (_locationQuery.IsLocationSynonym(country, location, namedLocation))
            {
                return(location);
            }

            return(namedLocation.ToString());
        }
Exemple #2
0
        async Task MakeRideOrOfferTo(NamedLocation destination)
        {
            if (!(App.Current.Rides.RidesharingState is NoneState))
            {
                return;
            }

            bool isOffer = false;

            if (App.Current.UserInfo.DriverInfo != null && App.Current.UserInfo.DriverInfo.Cars.Count > 0)
            {
                isOffer = await this.GetPageParent()?.DisplayAlert("Offer or request?", "Which is it?", "Offer", "Request");
            }

            NamedLocation origin = new NamedLocation("Current Location",
                                                     (await CrossGeolocator.Current.GetPositionAsync()).ToGeoCoordinates());

            if (isOffer)
            {
                await OfferRide(origin, destination);
            }
            else
            {
                await RequestRide(origin, destination);
            }
        }
        public RideRelatedRequestViewModel(
            Func <RequestBase, Task> submit,
            Func <Task> cancel,
            Action <GeoCoordinates, Action <NamedLocation> > pickLocation,
            NamedLocation start,
            NamedLocation end)
        {
            this.start    = start;
            this.end      = end;
            departureTime = DateTime.Now;

            SubmitRequestCommand = new AsyncCommand(SubmitWrapper, null, App.Current.ErrorHandler);
            CancelRequestCommand = new AsyncCommand(CancelWrapper, null, App.Current.ErrorHandler);

            this.pickLocation = pickLocation;

            async Task SubmitWrapper()
            {
                using (var token = DisplayActivityIndicator?.Invoke())
                    await submit(MakeRequest());
            }

            async Task CancelWrapper()
            {
                using (var token = DisplayActivityIndicator?.Invoke())
                    await cancel();
            }
        }
Exemple #4
0
        private JobAd PostJobAd(Industry industry, NamedLocation location)
        {
            var employer = _employerAccountsCommand.CreateTestEmployer(UserId, _organisationsCommand.CreateTestOrganisation(0));
            var jobAd    = employer.CreateTestJobAd("Manager", "Blah blah blah", industry, new LocationReference(location));

            _jobAdsCommand.PostJobAd(jobAd);
            return(jobAd);
        }
 public RideOfferViewModel(
     Func <RequestBase, Task> submit,
     Func <Task> cancel,
     Action <GeoCoordinates, Action <NamedLocation> > pickLocation,
     NamedLocation start,
     NamedLocation end)
     : base(submit, cancel, pickLocation, start, end)
 {
 }
        /**
         * Displays a {@link LiteListDemoActivity.NamedLocation} on a
         * {@link com.google.android.gms.maps.GoogleMap}.
         * Adds a marker and centers the camera on the NamedLocation with the normal map type.
         *
         * @param map
         * @param data
         */
        private static void setMapLocation(GoogleMap map, NamedLocation data)
        {
            // Add a marker for this item and set the camera
            map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(data.Location, 13f));
            map.AddMarker(new MarkerOptions().SetPosition(data.Location));

            // Set the map type back to normal.
            map.MapType = GoogleMap.MapTypeNormal;
        }
Exemple #7
0
        public static string GetRecord(string displayName, NamedLocation namedLocation, bool includeId, bool includeType)
        {
            var sb = new StringBuilder();

            if (includeId)
            {
                sb.Append(namedLocation.Id);
            }

            string type;

            if (namedLocation is CountrySubdivision)
            {
                var cs = (CountrySubdivision)namedLocation;
                if (cs.IsCountry)
                {
                    type        = CountryType;
                    displayName = AnywherePrefix + cs.Country.Name;
                }
                else
                {
                    type = CountrySubdivisionType;
                    if (displayName == null)
                    {
                        displayName = cs.Name;
                    }
                }
            }
            else if (namedLocation is Region)
            {
                type = RegionType;
            }
            else if (namedLocation is PostalSuburb)
            {
                type = PostalSuburbType;
            }
            else
            {
                throw new ArgumentException("List item of type '" + namedLocation.GetType() + "' is unknown.");
            }

            if (includeType)
            {
                sb.Append(TypeDivider).Append(type);
            }
            if (includeId)
            {
                sb.Append(NameDivider);
            }
            if (displayName == null)
            {
                displayName = namedLocation.ToString();
            }
            sb.Append(displayName);
            return(sb.ToString());
        }
Exemple #8
0
        public async Task <NamedLocation> StoreNamedLocation(NamedLocation namedLocation)
        {
            if (namedLocation.Id == Guid.Empty)
            {
                namedLocation.Id = Guid.NewGuid();
            }

            // TODO validate
            var result = await _db.NamedLocationCollection.ReplaceOneAsync(GetIdFilterNamedLocation(namedLocation.Id), namedLocation, _db.UpsertOptions);

            return(namedLocation);
        }
        private void LoadSavedLocations()
        {
            // Load the locations from the hidden field.

            int[] locationIds = StringUtils.ParseArrayFromString <int>(",", hidSuggestionIds.Value);
            if (!locationIds.IsNullOrEmpty())
            {
                var locations = new NamedLocation[locationIds.Length];
                for (int i = 0; i < locations.Length; i++)
                {
                    locations[i] = LocationQuery.GetNamedLocation(locationIds[i], true);
                }

                rptLocations.DataSource = locations;
                DataBind();
            }
        }
Exemple #10
0
        /// <summary>
        /// Create new navigation property to namedLocations for identity
        /// <param name="body"></param>
        /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
        /// </summary>
        public RequestInformation CreatePostRequestInformation(NamedLocation body, Action <NamedLocationsRequestBuilderPostRequestConfiguration> requestConfiguration = default)
        {
            _ = body ?? throw new ArgumentNullException(nameof(body));
            var requestInfo = new RequestInformation {
                HttpMethod     = Method.POST,
                UrlTemplate    = UrlTemplate,
                PathParameters = PathParameters,
            };

            requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
            if (requestConfiguration != null)
            {
                var requestConfig = new NamedLocationsRequestBuilderPostRequestConfiguration();
                requestConfiguration.Invoke(requestConfig);
                requestInfo.AddRequestOptions(requestConfig.Options);
                requestInfo.AddHeaders(requestConfig.Headers);
            }
            return(requestInfo);
        }
Exemple #11
0
 public static string ToString(NamedLocation namedLocation, CountrySubdivision subdivision, bool hasSubdivisionAccess, bool hasSubSubdivisionAccess)
 {
     if (namedLocation is Locality)
     {
         return(ToString((Locality)namedLocation, subdivision, hasSubdivisionAccess, hasSubSubdivisionAccess));
     }
     if (namedLocation is PostalCode)
     {
         return(ToString((PostalCode)namedLocation, subdivision, hasSubdivisionAccess, hasSubSubdivisionAccess));
     }
     if (namedLocation is Region)
     {
         return(ToString((Region)namedLocation));
     }
     if (namedLocation is PostalSuburb)
     {
         return(ToString((PostalSuburb)namedLocation, hasSubdivisionAccess, hasSubSubdivisionAccess));
     }
     if (namedLocation is CountrySubdivision)
     {
         return(ToString((CountrySubdivision)namedLocation, hasSubdivisionAccess));
     }
     return(string.Empty);
 }
Exemple #12
0
 void OnSearchBarLocation(NamedLocation location)
 {
     MakeRideOrOfferTo(location).FireAndForgetAsync(App.Current.ErrorHandler);
 }
Exemple #13
0
 private static void AssertLink(ReadOnlyUrl url, NamedLocation subdivision, HtmlNode node)
 {
     Assert.AreEqual(url.Path.ToLower(), node.Attributes["href"].Value.ToLower());
     Assert.AreEqual(subdivision.Name + " jobs", HttpUtility.HtmlDecode(node.InnerText));
 }
Exemple #14
0
 public bool IsLocationSynonym(Country country, string location, NamedLocation namedLocation)
 {
     throw new System.NotImplementedException();
 }
Exemple #15
0
 private string ResolveRegion(Country country, NamedLocation region, string location)
 {
     return(ResolveNamedLocation(country, region, location));
 }
Exemple #16
0
 private string ResolveLocality(Country country, NamedLocation locality, string location)
 {
     return(ResolveNamedLocation(country, locality, location));
 }
 internal LocationChosenEventArgs(NamedLocation location)
 {
     _location = location;
 }
        private void rptLocalities_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            NamedLocation location = LocationQuery.GetNamedLocation(int.Parse(e.CommandArgument.ToString()));

            OnLocationChosen(new LocationChosenEventArgs(location));
        }
Exemple #19
0
 private string ResolvePostalCode(Country country, NamedLocation postalCode, string location)
 {
     return(ResolveNamedLocation(country, postalCode, location));
 }
 private static void AssertLink(ReadOnlyUrl url, NamedLocation subdivision, HtmlNode node)
 {
     Assert.AreEqual(url.ToString().ToLower(), new ReadOnlyApplicationUrl(node.Attributes["href"].Value).ToString().ToLower());
     Assert.AreEqual(subdivision.Name, HttpUtility.HtmlDecode(node.InnerText));
 }
Exemple #21
0
 bool ILocationQuery.IsLocationSynonym(Country country, string location, NamedLocation namedLocation)
 {
     CheckInitialised();
     return(country.IsLocationSynonym(location, namedLocation));
 }
Exemple #22
0
        async Task RequestRide(NamedLocation origin, NamedLocation destination)
        {
            if (!(App.Current.Rides.RidesharingState is NoneState currentState))
            {
                return;
            }

            RideRequestViewModel rideRequestViewModel =
                new RideRequestViewModel(
                    async(req) =>
            {
                var request = req as RideRequest;

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

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

                    await this.GetPageParent()?.DisplayAlert("Failed", "Failed to request ride.", "Ok");
                }
                else
                {
                    tagRideMap.RideInfoView(
                        new RideInfo(null, null,
                                     new Route(
                                         new Route.Stop[]
                    {
                        new Route.Stop(request.Trip.Source),
                        new Route.Stop(request.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 RideRequestView(rideRequestViewModel)
            }
                );
        }
Exemple #23
0
        public LocationMapper(ILocationQuery locationQuery)
        {
            _locationQuery = locationQuery;

            _knownAreasByState = new Dictionary <string, Dictionary <string, NamedLocation> >
            {
                { "VIC", _knownAreasVIC },
                { "TAS", _knownAreasTAS },
                { "NSW", _knownAreasNSW },
                { "ACT", _knownAreasACT },
                { "QLD", _knownAreasQLD },
                { "SA", _knownAreasSA },
                { "WA", _knownAreasWA },
                { "NT", _knownAreasNT },
            };

            _australia = ResolveLocation(string.Empty);
            _canberra  = ResolveLocation("Canberra");
            _sydney    = ResolveLocation("Sydney");
            _darwin    = ResolveLocation("Darwin");
            _brisbane  = ResolveLocation("Brisbane");
            _adelaide  = ResolveLocation("Adelaide");
            _hobart    = ResolveLocation("Hobart");
            _melbourne = ResolveLocation("Melbourne");
            _perth     = ResolveLocation("Perth");
            _goldCoast = ResolveLocation("Gold Coast");

            _newcastle   = ResolveLocation("2300");
            _shepparton  = ResolveLocation("3630");
            _sutherland  = ResolveLocation("1499");
            _gosford     = ResolveLocation("2250");
            _townsville  = ResolveLocation("4810");
            _bathurst    = ResolveLocation("2795");
            _cairns      = ResolveLocation("4870");
            _rockhampton = ResolveLocation("4700");
            _noosa       = ResolveLocation("4567");

            _knownAreasNSW.Add("Sydney Metro", _sydney);
            _knownAreasNSW.Add("Sydney", _sydney);
            _knownAreasNSW.Add("Sydney Inner Suburbs", _sydney);
            _knownAreasNSW.Add("Northern Beaches", _sydney);
            _knownAreasNSW.Add("Newcastle & Region", _newcastle);
            _knownAreasNSW.Add("Newcastle & Hunter", _newcastle);
            _knownAreasNSW.Add("Sutherland Shire", _sutherland);
            _knownAreasNSW.Add("Gosford & Central Coast", _gosford);
            _knownAreasNSW.Add("Bathurst & Central West NSW", _bathurst);

            _knownAreasVIC.Add("Melbourne Metro", _melbourne);
            _knownAreasVIC.Add("Melbourne", _melbourne);
            _knownAreasVIC.Add("Melbourne Inner Suburbs", _melbourne);
            _knownAreasVIC.Add("Bayside", _melbourne);
            _knownAreasVIC.Add("Mornington Peninsula", _melbourne);
            _knownAreasVIC.Add("Shepparton & Central North", _shepparton);

            _knownAreasQLD.Add("Brisbane Metro", _brisbane);
            _knownAreasQLD.Add("Brisbane Inner Suburbs", _brisbane);
            _knownAreasQLD.Add("Gold Coast", _goldCoast);
            _knownAreasQLD.Add("Gold Coast & Hinterland", _goldCoast);
            _knownAreasQLD.Add("Townsville & Region", _townsville);
            _knownAreasQLD.Add("Cairns & Region", _cairns);
            _knownAreasQLD.Add("Rockhampton & Region", _rockhampton);
            _knownAreasQLD.Add("Sunshine Coast", _noosa);
            _knownAreasQLD.Add("Sunshine Coast & Region", _noosa);

            _knownAreasWA.Add("Perth Metro", _perth);
            _knownAreasWA.Add("Perth Inner Suburbs", _perth);

            _knownAreasSA.Add("Adelaide Metro", _adelaide);
            _knownAreasSA.Add("Adelaide Inner Suburbs", _adelaide);

            _knownAreasTAS.Add("Hobart Metro", _hobart);

            _knownAreasNT.Add("Darwin Metro", _darwin);
            _knownAreasNT.Add("Darwin Metro Area", _darwin);

            _knownAreasACT.Add("Canberra & ACT", _canberra);
        }
Exemple #24
0
 public static string ToString(NamedLocation namedLocation)
 {
     return(ToString(namedLocation, World.GetCountrySubdivision(namedLocation), true, true));
 }