private async void FillPreferencesCountry() { IsOperationInProgress = true; _dbWrapper = new DbWrapper(); _userManager = new UserManager(_dbWrapper); var preferences = await Task.Run(() => _dbWrapper.GetAllPreferences()); // var preferencesUseit Task.Run(() => _userManager.GetPreferencesCountryUser(UserName)); List <string> preferencesUser = _userManager.GetPreferencesCountryUser(UserManager.CurrentUser.UserName); CountriesGridView.ItemsSource = preferences.Where(c => c.Category == "Country").Select(d => d.Name).ToArray(); foreach (string i in preferencesUser) { if (CountriesGridView.Items != null) { foreach (var j in CountriesGridView.Items) { if (j.ToString().Equals(i)) { CountriesGridView.SelectedItems.Add(j); } } } } IsOperationInProgress = false; }
private async void FillPreferencesAndGroups() { IsOperationInProgress = true; DbWrapper = new DbWrapper(); UserManager = new UserManager(DbWrapper); GroupManager = new GroupManager(DbWrapper); var preferences = await Task.Run(() => DbWrapper.GetAllPreferences()); var groups = await Task.Run(() => GroupManager.GetAllGroups()); CountriesGridView.ItemsSource = preferences.Where(c => c.Category == "Country").Select(d => d.Name).ToArray(); TypesGridView.ItemsSource = preferences.Where(c => c.Category == "Type").Select(d => d.Name).ToArray(); GroupsGridView.ItemsSource = groups.Select(c => c.Trim()).ToArray(); IsOperationInProgress = false; }