public ActionResult Highscores(int gID = -1) { IEnumerable <HighScore> highScores = new List <HighScore>(); IEnumerable <Player> players = new List <Player>(); IEnumerable <Game> games = new List <Game>(); List <object> idata = new List <object>(); highScores = gID > -1 ? hsTable.GetAll().Where(h => h.gID == gID) : hsTable.GetAll(); players = pTable.GetAll(); games = gID > -1 ? gTable.GetAll().Where(h => h.ID == gID) : gTable.GetAll(); IEnumerable <ChartViewModel> scoreBoard = (from h in highScores join p in players on h.pID equals p.ID join g in games on h.gID equals g.ID select new ChartViewModel { Name = p.Name, Highscore = h.Highscore, GameType = g.Name }); idata = GetListData(scoreBoard); ViewBag.ChartData = idata.ToArray(); return(View()); }
public ActionResult Index() { IEnumerable <HighScore> highScores = highscoreTable.GetAll(); IEnumerable <Player> players = playerTable.GetAll(); IEnumerable <Game> games = gameTable.GetAll(); try { IEnumerable <ScoreboardViewModel> scoreboard = from h in highScores join p in players on h.pID equals p.ID join g in games on h.gID equals g.ID select new ScoreboardViewModel { Highscore = h.Highscore, PlayerName = p.Name, GameMode = g.Name, lastScored = h.LastUpdated }; ViewBag.Title = "Scoreboard"; return(View(scoreboard)); } catch { return(View("Home")); } }
public ActionResult HomePage(HomeViewModel homeViewModel) { IEnumerable <HighScore> highScores = hsTable.GetAll(); IEnumerable <PvP> pvpStats = plTable.GetAll(); try { int iD = Convert.ToInt32(Session["id"]); PvP userPVP = pvpStats.Where(p => p.ID == iD).FirstOrDefault(); HighScore userHS = highScores.Where(h => h.pID == iD).FirstOrDefault(); homeViewModel.highScore = userHS; homeViewModel.pvpStat = userPVP; homeViewModel.Name = Convert.ToString(Session["name"]); return(View(homeViewModel)); } catch { return(View("Error")); } }