Ejemplo n.º 1
0
        public async Task <List <BienImmoLight> > RefreshDataAsync(RequestGPSDto requestGPSDto)
        {
            Biens = new List <BienImmoLight>();
            var uri = new Uri(string.Format(Constants.RestUrl, string.Empty));

            try
            {
                var json    = JsonConvert.SerializeObject(requestGPSDto);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;

                response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    Biens = JsonConvert.DeserializeObject <List <BienImmoLight> >(result);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(@"ERROR {0}", e.Message);
            }

            return(Biens);
        }
Ejemplo n.º 2
0
        public IEnumerable <BienImmoLight> GetBiensLight(RequestGPSDto req)
        {
            String isMaison      = "";
            String isAppartement = "";
            String isSale        = "";
            String isRental      = "";

            if (req.filtre.isMaison)
            {
                isMaison = "Maison";
            }
            if (req.filtre.isAppartement)
            {
                isAppartement = "Appartement";
            }
            if (req.filtre.isSale)
            {
                isSale = "Vente";
            }
            if (req.filtre.isRental)
            {
                isRental = "Location";
            }

            double earthRadius = 6378137;
            double latPlus     = req.coordLat + (req.filtre.aireRecherche / earthRadius) * (180 / Math.PI);
            double latMoins    = req.coordLat - (req.filtre.aireRecherche / earthRadius) * (180 / Math.PI);
            double longMoins   = req.coordLong - (req.filtre.aireRecherche / (earthRadius * Math.Cos(Math.PI * req.coordLat / 180))) * (180 / Math.PI);
            double longPlus    = req.coordLong + (req.filtre.aireRecherche / (earthRadius * Math.Cos(Math.PI * req.coordLat / 180))) * (180 / Math.PI);

            lock (locker)
            {
                return((from i in database.Table <BienImmoLight>().Where(u => (u.typeBien == isMaison ||
                                                                               u.typeBien == isAppartement) &&
                                                                         (u.type == isSale ||
                                                                          u.type == isRental) &&
                                                                         u.coordLat >= latMoins &&
                                                                         u.coordLat <= latPlus &&
                                                                         u.coordLong >= longMoins &&
                                                                         u.coordLong <= longPlus &&
                                                                         u.surface >= req.filtre.surfaceMin &&
                                                                         u.surface <= req.filtre.surfaceMax &&
                                                                         u.prix >= req.filtre.prixMin &&
                                                                         u.prix <= req.filtre.prixMax) select i).ToList());
            }
        }
Ejemplo n.º 3
0
        public async Task ExecuteGetBiensSQLite(Position position)
        {
            RequestGPSDto req    = new RequestGPSDto();
            Filtre        filtre = new Filtre();

            req.coordLat         = position.Latitude;
            req.coordLong        = position.Longitude;
            filtre.aireRecherche = Settings.aireRecherche * 1000;
            filtre.prixMax       = Settings.prixMax;
            filtre.prixMin       = Settings.prixMin;
            filtre.surfaceMax    = Settings.surfaceMax;
            filtre.surfaceMin    = Settings.surfaceMin;
            filtre.isMaison      = Settings.isMaison;
            filtre.isAppartement = Settings.isAppartement;
            filtre.isSale        = Settings.isSale;
            filtre.isRental      = Settings.isRental;

            req.filtre = filtre;

            BiensLight = App.Database.GetBiensLight(req);
        }
Ejemplo n.º 4
0
        async void On3DModelClicked(object sender, EventArgs e)
        {
            var           showAlert = false;
            RequestGPSDto req       = new RequestGPSDto();

            showAlert = await App.BienManager.CheckWs(req);

            if (!CrossConnectivity.Current.IsConnected)
            {
                await DisplayAlert("No signal detected", "This feature only works if you can reach the Internet.", "OK");
            }
            else if (showAlert)
            {
                await DisplayAlert("Oops, our server seems to be down", "Please come back later, you will certainly be able to download the 3D model.", "OK");
            }
            else
            {
                var model = new ARPage(bien.Id);
                await Navigation.PushAsync(model);
            }
        }
Ejemplo n.º 5
0
        public async Task ExecuteGetBiensCommand(Position position)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            var showAlert = false;

            RequestGPSDto req    = new RequestGPSDto();
            Filtre        filtre = new Filtre();

            req.coordLat         = position.Latitude;
            req.coordLong        = position.Longitude;
            filtre.aireRecherche = Settings.aireRecherche * 1000;
            filtre.prixMax       = Settings.prixMax;
            filtre.prixMin       = Settings.prixMin;
            filtre.surfaceMax    = Settings.surfaceMax;
            filtre.surfaceMin    = Settings.surfaceMin;
            filtre.isMaison      = Settings.isMaison;
            filtre.isAppartement = Settings.isAppartement;
            filtre.isSale        = Settings.isSale;
            filtre.isRental      = Settings.isRental;

            req.filtre = filtre;
            try
            {
                if (!CrossConnectivity.Current.IsConnected)
                {
                    await page.DisplayAlert("No signal detected", "Only previously loaded properties will be shown.", "OK");
                }
                else
                {
                    showAlert = await App.BienManager.CheckWs(req);

                    if (showAlert)
                    {
                        await page.DisplayAlert("Oops, our server seems to be down", "Only previously loaded properties will be shown.", "OK");
                    }
                    else
                    {
                        var biens = await App.BienManager.GetTaskAsync(req);

                        foreach (var item in biens)
                        {
                            App.Database.SaveBien(item);
                            BienImmo bienRest = new BienImmo();
                            bienRest = await App.BienManager.GetBienAsync(item.Id);

                            App.Database.SaveBienDetailed(bienRest);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(@"ERROR {0}", e.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
 public Task <bool> CheckWs(RequestGPSDto req)
 {
     return(restService.CheckWs(req));
 }
 public Task <List <BienImmoLight> > GetTaskAsync(RequestGPSDto req)
 {
     return(restService.RefreshDataAsync(req));
 }