async Task <List <NewsCategory> > GetSavedUserInterests() { List <NewsCategory> usersFavoriteNewsCategories = new List <NewsCategory>(); var userInterests = await GetUserInterestsFromCosmos(); // Now loop through all the user interests // finding the match inside of the AllNewsCategories mark it as a fave // then add that fave to the return list var allNewsCategories = new AllNewsCategories(); foreach (var item in userInterests) { var newsCategory = allNewsCategories.FirstOrDefault(nc => nc.CategoryName == item.NewsCategoryName); newsCategory.IsFavorite = true; usersFavoriteNewsCategories.Add(newsCategory); } return(usersFavoriteNewsCategories); }
async Task <List <NewsCategory> > GetSavedUserInterests() { List <NewsCategory> usersFavoriteNewsCategories = new List <NewsCategory>(); var userInterests = await GetUserInterestsFromCosmos(); if (userInterests == null) { // try signing in again - most likey token expired await authService.Login(); isCosmosInitialized = false; userInterests = await GetUserInterestsFromCosmos(); // just keep on going - it's a demo if (userInterests == null) { userInterests = new List <UserInterest>(); } } // Now loop through all the user interests // finding the match inside of the AllNewsCategories mark it as a fave // then add that fave to the return list var allNewsCategories = new AllNewsCategories(); foreach (var item in userInterests) { var newsCategory = allNewsCategories.FirstOrDefault(nc => nc.CategoryName == item.NewsCategoryName); newsCategory.IsFavorite = true; usersFavoriteNewsCategories.Add(newsCategory); } return(usersFavoriteNewsCategories); }