Пример #1
0
        async void OnTapGestureRecognizerTapped(object sender, EventArgs args)
        {
            BienImmo bienBdd = new BienImmo();

            bienBdd = App.Database.GetSingleBien(current);

            var bienPage = new BienPage(bienBdd);
            await Navigation.PushAsync(bienPage);
        }
Пример #2
0
        async void OnPinClicked(int id)
        {
            BienImmo bienBdd = new BienImmo();

            bienBdd = App.Database.GetSingleBien(id);

            var bienPage = new BienPage(bienBdd);
            await Navigation.PushAsync(bienPage);
        }
Пример #3
0
        public int SaveBienDetailed(BienImmo item)
        {
            lock (locker)
            {
                if (GetSingleBien(item.Id) != null)
                {
                    if (GetSingleBien(item.Id).isFavorite)
                    {
                        item.isFavorite = true;
                    }

                    return(database.Update(item));
                }
                else
                {
                    return(database.Insert(item));
                }
            }
        }
Пример #4
0
        public async Task <BienImmo> GetBienImmo(int id)
        {
            Bien = new BienImmo();

            var uri = new Uri(string.Format(Constants.RestUrlGetBiens + id, string.Empty));

            try
            {
                var response = await client.GetAsync(uri);

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

                    Bien = JsonConvert.DeserializeObject <BienImmo>(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"ERROR {0}", ex.Message);
            }

            return(Bien);
        }
Пример #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;
            }
        }
Пример #6
0
        public BienPage(BienImmo bien)
        {
            InitializeComponent();
            this.bien = bien;
            favorites = new FavoriteCheck
            {
                Checked           = bien.isFavorite,
                HorizontalOptions = LayoutOptions.EndAndExpand,
            };

            favorites.Clicked += OnFavClicked;

            button = new Button
            {
                Text = "3D Model"
            };
            button.Clicked += On3DModelClicked;

            map = new Map
            {
                HeightRequest   = 300,
                WidthRequest    = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(bien.CoordLat, bien.CoordLong), Distance.FromMiles(1.2)));

            var pin = new Pin
            {
                Type     = PinType.Place,
                Position = new Position(bien.CoordLat, bien.CoordLong),
                Label    = bien.Titre,
                Address  = bien.Soustitre
            };

            map.Pins.Add(pin);

            StackLayout stackLayout = new StackLayout
            {
                Spacing  = 0,
                Padding  = 10,
                Children =
                {
                    new StackLayout   {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new Label
                            {
                                Text           = bien.Titre,
                                FontAttributes = FontAttributes.Bold
                            },
                            favorites
                        }
                    },

                    new Label         {
                        Text     = bien.Soustitre,
                        FontSize = 11,
                        Margin   = new Thickness(0, 0, 0, 15)
                    },
                    new Image         {
                        Source        = bien.Photo,
                        HeightRequest = 150,
                        Margin        = new Thickness(0, 0, 0, 15)
                    },
                    new Label         {
                        Text           = "Description",
                        FontAttributes = FontAttributes.Bold
                    },
                    new StackLayout   {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new Label {
                                Text     = "" + bien.Surface,
                                FontSize = 11
                            },
                            new Label {
                                Text     = "m²",
                                FontSize = 11
                            }
                        }
                    },
                    new StackLayout   {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new Label {
                                Text     = "" + bien.Prix,
                                FontSize = 11
                            },
                            new Label {
                                Text     = "€",
                                FontSize = 11,
                                Margin   = new Thickness(0, 0, 0, 15)
                            }
                        }
                    },
                    new Label         {
                        Text   = bien.Description,
                        Margin = new Thickness(0, 0, 0, 15)
                    },
                    new Label         {
                        Text           = "Address",
                        FontAttributes = FontAttributes.Bold,
                        Margin         = new Thickness(0, 0, 0, 15)
                    },
                    new Label         {
                        Text = bien.Adresse
                    },
                    new StackLayout   {
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new Label {
                                Text = bien.Ville
                            },
                            new Label {
                                Text   = bien.Cp,
                                Margin = new Thickness(0, 0, 0, 15)
                            }
                        }
                    },
                    new Label
                    {
                        Text           = "Contact",
                        FontAttributes = FontAttributes.Bold,
                        Margin         = new Thickness(0, 0, 0, 15)
                    },
                    new Label
                    {
                        Text = bien.Telephone
                    },
                    new Label
                    {
                        Text   = bien.Email,
                        Margin = new Thickness(0, 0, 0, 15)
                    },
                    new Label
                    {
                        Text           = "Map",
                        FontAttributes = FontAttributes.Bold,
                        Margin         = new Thickness(0, 0, 0, 15)
                    },
                    map,
                    button
                }
            };

            Content = new ScrollView
            {
                Content = stackLayout
            };
        }