Beispiel #1
0
        public async override void OnNavigatedTo(INavigationParameters parameters)
        {
            Debug.Write("FavAdvertViewModel OnNavigatedTo");
            base.OnNavigatedTo(parameters);

            if (parameters.ContainsKey("LoadFavAdvert"))
            {
                Activity = true;
                AdvertShortList.Clear();
                await _setting.GetFavoriteAdvertListDBAsync(AdvertShortList);

                Activity = false;
            }
        }
Beispiel #2
0
 protected async void DeleteAllAdverFromDb()
 {
     if (await _pageDialog.DisplayAlertAsync(_setting.GetAppNameAndVersion,
                                             "Czy napewno chcesz usunąć wszystkie ulubione ogłoszenia?", "Usuń wszystko", "Anuluj"))
     {
         if (await _setting.DeleteAdvertAllDBAsync())
         {
             _dependencyService.Get <IToast>().Show("Usunięto wszystkie ogłoszenia z bazy.");
             AdvertShortList.Clear();
         }
         else
         {
             _dependencyService.Get <IToast>().Show("Wystąpił błąd podczas usuwania ogłoszeń z bazy.");
         }
     }
 }
Beispiel #3
0
        protected async Task <bool> SearchExecute(AdvertSearch advertSearch, bool addLoad = false)
        {
            Debug.Write("SearchExecute");
            Activity     = true;
            ErrorMessage = String.Empty;

            _lastAdvertSearch = advertSearch;
            OnPropertyChanged("CurrentCategory");
            OnPropertyChanged("FilterButtonColor");

            if (advertSearch == null)
            {
                Debug.Write("SearchExecute => advertSearch == null");
                return(false);
            }

            if (addLoad)
            {
                FotterActivity = true;
                Activity       = false;
            }

            else
            {
                Activity       = true;
                FotterActivity = false;
                AdvertShortList.Clear();
            }

            var lastAddAdvert = await _rzeszowiakRepository.GetAdvertListAsync(advertSearch);

            if (!lastAddAdvert.Correct)
            {
                if (!addLoad)
                {
                    ErrorMessage = "Błąd podczas ładowania strony.\nSprawdź połączenie internetowe i spróbuj ponownie.";
                }
            }
            else
            {
                _lastAdvertSearchResult = lastAddAdvert;

                var adverId = new List <int>();
                foreach (var item in AdvertShortList)
                {
                    adverId.Add(item.AdverIDinRzeszowiak);
                }

                foreach (var item in lastAddAdvert.AdvertShortsList)
                {
                    if (adverId.IndexOf(item.AdverIDinRzeszowiak) != -1)
                    {
                        continue;
                    }
                    AdvertShortList.Add(item);
                    await Task.Delay(50);
                }

                if (AdvertShortList.Count == 0 && !addLoad)
                {
                    ErrorMessage = "Nic nie znaleziono.\nZmień kryteria wyszukiwania.";
                }
            }
            Activity       = false;
            FotterActivity = false;
            return(true);
        }