Пример #1
0
        public ContactDetailViewModel(ApiService apiService, ContactDatabase contactDatabase, IMainThread mainThread, AppCenterService appCenterService) : base(appCenterService)
        {
            _apiService      = apiService;
            _mainThread      = mainThread;
            _contactDatabase = contactDatabase;

            SaveButtonTappedCommand = new AsyncCommand <bool>(ExecuteSaveButtonTappedCommand, _ => !IsSaving);
        }
Пример #2
0
        async void HandleDeleteClicked(object sender, EventArgs e)
        {
            var contactSelected = (ContactModel)BindingContext;

            await Task.WhenAll(ApiService.DeleteContactModel(contactSelected.Id),
                               ContactDatabase.DeleteContact(contactSelected)).ConfigureAwait(false);

            ContactsListViewModel.RefreshCommand.Execute(null);
        }
Пример #3
0
        async void HandleDeleteClicked(object sender, EventArgs e)
        {
            var contactSelected = BindingContext as ContactModel;

            await Task.WhenAll(APIService.DeleteContactModel(contactSelected),
                               ContactDatabase.DeleteContact(contactSelected));

            ContactsListViewModel.RefreshCommand?.Execute(null);
        }
Пример #4
0
                            List <ContactModel> contactListFromRemoteDatabase)> GetAllSavedContacts()
        {
            var contactListFromLocalDatabaseTask  = ContactDatabase.GetAllContacts();
            var contactListFromRemoteDatabaseTask = APIService.GetAllContactModels();

            await Task.WhenAll(contactListFromLocalDatabaseTask, contactListFromRemoteDatabaseTask).ConfigureAwait(false);

            return(contactListFromLocalDatabaseTask.Result ?? new List <ContactModel>(),
                   contactListFromRemoteDatabaseTask.Result ?? new List <ContactModel>());
        }
Пример #5
0
                            IEnumerable <ContactModel> contactListFromRemoteDatabase)> GetAllSavedContacts()
        {
            var contactListFromLocalDatabaseTask  = ContactDatabase.GetAllContacts();
            var contactListFromRemoteDatabaseTask = ApiService.GetAllContactModels();

            await Task.WhenAll(contactListFromLocalDatabaseTask, contactListFromRemoteDatabaseTask).ConfigureAwait(false);

            return(await contactListFromLocalDatabaseTask.ConfigureAwait(false) ?? Enumerable.Empty <ContactModel>(),
                   await contactListFromRemoteDatabaseTask.ConfigureAwait(false) ?? Enumerable.Empty <ContactModel>());
        }
        public static async Task RemoveTestContactsFromLocalDatabase()
        {
            var contactsList = await ContactDatabase.GetAllContacts().ConfigureAwait(false);

            var testContactsList = contactsList.Where(x =>
                                                      x.FirstName.Equals(TestConstants.TestFirstName) &&
                                                      x.LastName.Equals(TestConstants.TestLastName) &&
                                                      x.PhoneNumber.Equals(TestConstants.TestPhoneNumber)).ToList();

            var removedContactTaskList = new List <Task>();

            foreach (var contact in testContactsList)
            {
                removedContactTaskList.Add(ContactDatabase.RemoveContact(contact));
            }

            await Task.WhenAll(removedContactTaskList).ConfigureAwait(false);
        }
        public ContactsListViewModel(ApiService apiService,
                                     ContactDatabase contactDatabase,
                                     AppCenterService appCenterService,
                                     DatabaseSyncService databaseSyncService) : base(appCenterService)
        {
            _apiService          = apiService;
            _contactDatabase     = contactDatabase;
            _databaseSyncService = databaseSyncService;

            RefreshCommand = new AsyncCommand(() =>
            {
                AppCenterService.Track(AppCenterConstants.PullToRefreshTriggered);
                return(ExecuteRefreshCommand());
            });

            RestoreDeletedContactsCommand = new AsyncCommand(() =>
            {
                AppCenterService.Track(AppCenterConstants.RestoreDeletedContactsTapped);
                return(ExecuteRestoreDeletedContactsCommand());
            });
        }
Пример #8
0
 public DatabaseSyncService(ContactDatabase contactDatabase, ApiService apiService) =>
 (_contactDatabase, _apiService) = (contactDatabase, apiService);
 public UITestBackdoorMethodService(ContactDatabase contactDatabase, IMainThread mainThread) =>
 (_contactDatabase, _mainThread) = (contactDatabase, mainThread);