public IActionResult CompareStats() { TempData.Clear(); var currentFavourites = _favouriteRepository.GetCurrentUserFavourites(); if (currentFavourites.Count() == 0) { TempData["noFavouritesMessage"] = "You don't have any favourites yet. Do a search and add some!"; } return(View()); }
public async Task <IActionResult> ListFavourites() { var currentFavourites = _favouriteRepository.GetCurrentUserFavourites(); Dictionary <PlayerInfo, FileModel> combinedPlayerAndImage = new Dictionary <PlayerInfo, FileModel>(); PlayerInfo currentFavouriteInfo = new PlayerInfo(); FileModel currentPlayerImage = new FileModel(); //get up-to-date data on each favourite from the API and add to list foreach (var f in currentFavourites) { currentFavouriteInfo = await _cricApiRepository.GetPlayerInfo(f.Pid); currentPlayerImage = _fileRepository.GetImageByFavouriteId(f.Id); combinedPlayerAndImage.Add(currentFavouriteInfo, currentPlayerImage); } return(View(new FavouritesViewModel { CombinedPlayersAndImages = combinedPlayerAndImage })); }
public IActionResult DefaultNewsList() { List <Favourite> currentUserFavourites = _favouriteRepository.GetCurrentUserFavourites(); List <string> currentFavouritePlayerNames = new List <string>(); List <NewsItems> newsItemsList = new List <NewsItems>(); foreach (Favourite fav in currentUserFavourites) { currentFavouritePlayerNames.Add(fav.Name); } bool hasNoFavouritedPlayers = currentUserFavourites.Count == 0; bool has1FavouritePlayers = currentUserFavourites.Count == 1; bool has2FavouritePlayers = currentUserFavourites.Count == 2; if (hasNoFavouritedPlayers) { TempData["noFavouritesMessage"] = "You have no favourited players. Please search for players and add them to your favourites."; return(View("NewsList")); } else if (has1FavouritePlayers) { return(RedirectToAction("NewsForSelectedPlayer", new { name = currentFavouritePlayerNames[0] })); } else if (has2FavouritePlayers) { return(RedirectToAction(nameof(ShowNewsFor2Favourites), new { currentFavouritePlayerNames = currentFavouritePlayerNames, newsItemsList = newsItemsList })); } //user has 3 or more favourited players else { return(ShowNewsFor3OrMoreFavourites(currentFavouritePlayerNames, newsItemsList)); } }
public IViewComponentResult Invoke() { List <Favourite> currentFavourites = _favouriteRepository.GetCurrentUserFavourites(); return(View(currentFavourites)); }