Esempio n. 1
0
        private async Task DeleteHistory()
        {
            const string filtered = "filtered";
            const string complete = "complete";
            var          message  = $"Do you realy want to delete the {(UndoFilterCommand.IsEnabled ? filtered : complete)} History?";
            var          delete   = await _uiService.DisplayAlert(message);

            if (delete)
            {
                await _uiService.ShowActivityPopup("deleting ...");

                var itemsToDelete = UndoFilterCommand.IsEnabled ? await _repository.FindAll <SyncLog>(_ => _.StartDate <= _startDate && _.EndDate >= _endDate) : await _repository.GetAll <SyncLog>();

                if (itemsToDelete.Any())
                {
                    _repository.DeleteRange(itemsToDelete);
                    _syncLogsInternal.Clear();
                }
                if (itemsToDelete.Any() || !itemsToDelete.Any())
                {
                    await _uiService.RemoveActivityPopup();
                }
            }
        }
Esempio n. 2
0
 public MainViewModel(ISyncService syncService, IRepository repository, IUiService uiService)
 {
     _syncService = syncService;
     _repository  = repository;
     SyncCommand  = new RelayCommand(OnSyncCommand)
     {
         IsEnabled = false
     };
     StartDate              = DateTime.Today.AddDays(-7);
     EndDate                = DateTime.Today.AddDays(30);
     LoginHintEnabled       = true;
     _searchResultsInternal = new ObservableRangeCollection <SearchResult>();
     SearchResults          = new ReadOnlyObservableCollection <SearchResult>(_searchResultsInternal);
     SearchCommand          = new RelayCommand(OnSearchCommand);
     SetInternetConnection();
     Connectivity.ConnectivityChanged   += Connectivity_ConnectivityChanged;
     SearchResultSelectionChangedCommand = new Command <SearchResult>(SearchResultSelectionChanged);
     _uiService = uiService;
     _syncService.AfterLogin = () => Device.BeginInvokeOnMainThread(async() => await _uiService.ShowActivityPopup("downloading calendar entries ..."));
 }